@fileverse-dev/ddoc 3.0.96-zustand-21 → 3.0.97-fragment-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.
@@ -1,4 +1,4 @@
1
1
  import { CommentCardProps } from './types';
2
2
 
3
- export declare const CommentCard: ({ username, comment, createdAt, replies, onResolve, onDelete: _onDelete, onRequestDelete, onUnresolve, isResolved, isDropdown, activeCommentId, id, isDisabled, isCommentOwner, version, emptyComment, }: CommentCardProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const CommentCard: ({ username, selectedContent, comment, createdAt, replies, onResolve, onDelete, onUnresolve, isResolved, isDropdown, activeCommentId, id, isDisabled, isCommentOwner, version, emptyComment, }: CommentCardProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export declare const UserDisplaySkeleton: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { CommentContextType, CommentProviderProps } from './types';
2
+
3
+ export declare const CommentProvider: ({ children, editor, ydoc, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, activeTabId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const useComments: () => CommentContextType;
@@ -1,51 +1,100 @@
1
- import { Dispatch, RefObject, SetStateAction } from 'react';
1
+ import { Editor } from '@tiptap/react';
2
2
  import { IComment } from '../../../extensions/comment';
3
- import { CommentStoreState } from '../../../stores/comment-store';
4
- import { CommentStoreProviderProps } from '../../../stores/comment-store-provider';
5
- import { CommentAccountProps } from '../../../types';
3
+ import { SetStateAction } from 'react';
4
+ import { CommentAccountProps, CommentMutationMeta } from '../../../types';
5
+ import { EnsStatus } from '../types';
6
6
 
7
- export interface CommentFloatingBaseItem {
8
- itemId: string;
7
+ import * as Y from 'yjs';
8
+ export interface CommentContextType extends CommentAccountProps {
9
+ comments: IComment[];
10
+ setComments: React.Dispatch<SetStateAction<IComment[]>>;
11
+ editor: Editor;
12
+ username?: string | null;
13
+ setUsername?: React.Dispatch<SetStateAction<string>>;
14
+ showResolved: boolean;
15
+ setShowResolved: (show: boolean) => void;
16
+ resolveComment: (commentId: string) => void;
17
+ unresolveComment: (commentId: string) => void;
18
+ deleteComment: (commentId: string) => void;
19
+ handleAddReply: (activeCommentId: string, replyContent: string, onCommentReply: (activeCommentId: string, reply: IComment) => void) => void;
20
+ focusCommentInEditor: (commentId: string) => void;
21
+ handleReplyChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
22
+ handleCommentChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
23
+ handleCommentKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
24
+ handleReplySubmit: () => void;
25
+ toggleResolved: () => void;
26
+ openReplyId: string | null;
27
+ setOpenReplyId: (id: string | null) => void;
28
+ handleReplyKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
29
+ commentsSectionRef: React.RefObject<HTMLDivElement>;
30
+ replySectionRef: React.RefObject<HTMLDivElement>;
31
+ addComment: (content?: string) => void;
32
+ handleCommentSubmit: () => void;
33
+ reply: string;
34
+ setReply: React.Dispatch<React.SetStateAction<string>>;
35
+ comment: string;
36
+ setComment: React.Dispatch<React.SetStateAction<string>>;
37
+ onPrevComment: () => void;
38
+ onNextComment: () => void;
39
+ activeCommentIndex: number;
40
+ activeComment: IComment | undefined;
9
41
  selectedText: string;
10
- isOpen: boolean;
11
- isFocused: boolean;
12
- }
13
- export interface CommentFloatingDraftItem extends CommentFloatingBaseItem {
14
- type: 'draft';
15
- draftId: string;
16
- draftText: string;
17
- isAuthPending: boolean;
42
+ isCommentOpen: boolean;
43
+ isBubbleMenuSuppressed: boolean;
44
+ setIsBubbleMenuSuppressed: React.Dispatch<React.SetStateAction<boolean>>;
45
+ handleInlineComment: () => void;
46
+ portalRef: React.RefObject<HTMLDivElement>;
47
+ buttonRef: React.RefObject<HTMLDivElement>;
48
+ dropdownRef: React.RefObject<HTMLDivElement>;
49
+ activeComments: IComment[];
50
+ handleInput: (e: React.FormEvent<HTMLTextAreaElement>, content: string) => void;
51
+ isCommentActive: boolean;
52
+ isCommentResolved: boolean;
53
+ ensResolutionUrl: string;
54
+ activeTabId: string;
55
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
56
+ onComment?: () => void;
57
+ setCommentDrawerOpen?: React.Dispatch<React.SetStateAction<boolean>>;
58
+ inlineCommentData: {
59
+ inlineCommentText: string;
60
+ handleClick: boolean;
61
+ };
62
+ setInlineCommentData: React.Dispatch<React.SetStateAction<{
63
+ inlineCommentText: string;
64
+ handleClick: boolean;
65
+ }>>;
66
+ getEnsStatus: (walletAddress: string, setEnsStatus: React.Dispatch<React.SetStateAction<EnsStatus>>) => void;
67
+ ensCache: EnsCache;
18
68
  }
19
- export interface CommentFloatingThreadItem extends CommentFloatingBaseItem {
20
- type: 'thread';
21
- commentId: string;
69
+ export interface CommentProviderProps extends CommentAccountProps {
70
+ children: React.ReactNode;
71
+ editor: Editor;
72
+ ydoc: Y.Doc;
73
+ initialComments?: IComment[];
74
+ setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
75
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
76
+ onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
77
+ onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
78
+ onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
79
+ onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
80
+ username: string | null;
81
+ setUsername?: React.Dispatch<SetStateAction<string>>;
82
+ activeCommentId: string | null;
83
+ setActiveCommentId: React.Dispatch<React.SetStateAction<string | null>>;
84
+ activeTabId: string;
85
+ focusCommentWithActiveId: (id: string) => void;
86
+ ensResolutionUrl: string;
87
+ onInlineComment?: () => void;
88
+ onComment?: () => void;
89
+ setCommentDrawerOpen?: React.Dispatch<React.SetStateAction<boolean>>;
22
90
  }
23
- export type CommentFloatingItem = CommentFloatingDraftItem | CommentFloatingThreadItem;
24
- export interface InlineCommentData {
25
- highlightedTextContent?: string;
26
- inlineCommentText: string;
27
- handleClick: boolean;
91
+ export interface CommentUsernameProps extends CommentAccountProps {
92
+ username?: string | null;
93
+ setUsername?: React.Dispatch<SetStateAction<string>>;
94
+ isNavbarVisible?: boolean;
28
95
  }
29
96
  export interface EnsEntry {
30
97
  name: string;
31
98
  isEns: boolean;
32
99
  }
33
100
  export type EnsCache = Record<string, EnsEntry>;
34
- export type CommentProviderProps = CommentStoreProviderProps;
35
- export type CommentContextType = Pick<CommentStoreState, 'activeComment' | 'activeCommentIndex' | 'activeComments' | 'activeTabId' | 'addComment' | 'blurFloatingItem' | 'cancelFloatingDraft' | 'closeFloatingItem' | 'comment' | 'connectViaUsername' | 'connectViaWallet' | 'createFloatingDraft' | 'deleteComment' | 'deleteReply' | 'ensCache' | 'floatingItems' | 'focusCommentInEditor' | 'focusFloatingItem' | 'getEnsStatus' | 'handleAddReply' | 'handleCommentChange' | 'handleCommentKeyDown' | 'handleCommentSubmit' | 'handleInlineComment' | 'handleInput' | 'handleReplyChange' | 'handleReplyKeyDown' | 'handleReplySubmit' | 'inlineCommentData' | 'isBubbleMenuSuppressed' | 'isCommentActive' | 'isCommentOpen' | 'isCommentResolved' | 'isConnected' | 'isDDocOwner' | 'isDesktopFloatingEnabled' | 'isLoading' | 'onComment' | 'onNextComment' | 'onPrevComment' | 'openFloatingThread' | 'openReplyId' | 'reply' | 'resolveComment' | 'setComment' | 'setCommentDrawerOpen' | 'setInlineCommentData' | 'setIsBubbleMenuSuppressed' | 'setOpenReplyId' | 'setReply' | 'setShowResolved' | 'setUsername' | 'selectedText' | 'showResolved' | 'submitFloatingDraft' | 'toggleResolved' | 'unresolveComment' | 'updateFloatingDraftText' | 'username'> & {
36
- comments: IComment[];
37
- commentsSectionRef: RefObject<HTMLDivElement>;
38
- dropdownRef: RefObject<HTMLDivElement>;
39
- buttonRef: RefObject<HTMLDivElement>;
40
- portalRef: RefObject<HTMLDivElement>;
41
- replySectionRef: RefObject<HTMLDivElement>;
42
- editor: CommentStoreProviderProps['editor'];
43
- ensResolutionUrl: string;
44
- onCommentReply?: CommentStoreProviderProps['onCommentReply'];
45
- setComments?: Dispatch<SetStateAction<IComment[]>>;
46
- };
47
- export interface CommentUsernameProps extends CommentAccountProps {
48
- username?: string | null;
49
- setUsername?: Dispatch<SetStateAction<string>>;
50
- isNavbarVisible?: boolean;
51
- }
@@ -37,7 +37,6 @@ export interface CommentCardProps extends IComment {
37
37
  comment?: string;
38
38
  onResolve?: (commentId: string) => void;
39
39
  onDelete?: (commentId: string) => void;
40
- onRequestDelete?: (commentId: string) => void;
41
40
  onUnresolve?: (commentId: string) => void;
42
41
  isResolved?: boolean;
43
42
  isDropdown?: boolean;
@@ -46,14 +45,11 @@ export interface CommentCardProps extends IComment {
46
45
  isCommentOwner?: boolean;
47
46
  version?: string;
48
47
  emptyComment?: boolean;
49
- isFocused?: boolean;
50
48
  }
51
49
  export type CommentBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
52
50
  zoomLevel: string;
53
51
  };
54
52
  export interface CommentReplyProps {
55
- commentId: string;
56
- replyId: string;
57
53
  reply: string;
58
54
  username: string;
59
55
  createdAt: Date;
@@ -1,7 +1,5 @@
1
1
  import { Mark, Range } from '@tiptap/core';
2
2
  import { Mark as PMMark } from '@tiptap/pm/model';
3
- import { PluginKey, EditorState } from '@tiptap/pm/state';
4
- import { DecorationSet } from '@tiptap/pm/view';
5
3
 
6
4
  declare module '@tiptap/core' {
7
5
  interface Commands<ReturnType> {
@@ -30,18 +28,6 @@ declare module '@tiptap/core' {
30
28
  * Unset comment active
31
29
  */
32
30
  unsetCommentActive: () => ReturnType;
33
- /**
34
- * Add a local draft anchor that tracks through transactions.
35
- */
36
- setDraftComment: (draftId: string) => ReturnType;
37
- /**
38
- * Remove a local draft anchor.
39
- */
40
- unsetDraftComment: (draftId: string) => ReturnType;
41
- /**
42
- * Replace a draft anchor with a persisted comment mark.
43
- */
44
- promoteDraftComment: (draftId: string, commentId: string) => ReturnType;
45
31
  };
46
32
  }
47
33
  }
@@ -59,18 +45,6 @@ export interface CommentOptions {
59
45
  export interface CommentStorage {
60
46
  activeCommentId: string | null;
61
47
  }
62
- export interface DraftCommentRange {
63
- draftId: string;
64
- from: number;
65
- to: number;
66
- }
67
- interface DraftCommentPluginState {
68
- decorations: DecorationSet;
69
- drafts: Map<string, DraftCommentRange>;
70
- }
71
- export declare const draftCommentPluginKey: PluginKey<DraftCommentPluginState>;
72
- export declare const getDraftCommentState: (state: EditorState) => DraftCommentPluginState | undefined;
73
- export declare const getDraftCommentRange: (state: EditorState, draftId: string) => DraftCommentRange | null;
74
48
  export interface IComment {
75
49
  id?: string;
76
50
  tabId?: string;
@@ -89,4 +63,3 @@ export interface IComment {
89
63
  version?: string;
90
64
  }
91
65
  export declare const CommentExtension: Mark<CommentOptions, CommentStorage>;
92
- export {};
@@ -1,7 +1,6 @@
1
1
  import { Dispatch, MutableRefObject, SetStateAction } from 'react';
2
2
  import { DdocProps } from '../types';
3
3
  import { AnyExtension, Editor } from '@tiptap/react';
4
- import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
5
4
  import { ToCItemType } from '../components/toc/types';
6
5
  import { CollabConnectionConfig, CollaborationProps } from '../sync-local/types';
7
6
 
@@ -60,6 +59,5 @@ export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionI
60
59
  setActiveCommentId: Dispatch<SetStateAction<string | null>>;
61
60
  focusCommentWithActiveId: (id: string) => void;
62
61
  isContentLoading: boolean | undefined;
63
- commentAnchorsRef: MutableRefObject<CommentAnchor[]>;
64
62
  };
65
63
  export {};
@@ -22,16 +22,7 @@ export type InlineCommentData = {
22
22
  export type CommentMutationType = 'create' | 'resolve' | 'unresolve' | 'delete';
23
23
  export interface CommentMutationMeta {
24
24
  type: CommentMutationType;
25
- updateChunk?: string;
26
- anchorFrom?: string;
27
- anchorTo?: string;
28
- }
29
- export interface SerializedCommentAnchor {
30
- id: string;
31
- anchorFrom: string;
32
- anchorTo: string;
33
- resolved: boolean;
34
- deleted: boolean;
25
+ updateChunk: string;
35
26
  }
36
27
  export interface CommentAccountProps {
37
28
  isConnected?: boolean;
@@ -113,7 +104,6 @@ export interface DdocProps extends CommentAccountProps {
113
104
  commentDrawerOpen?: boolean;
114
105
  setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
115
106
  initialComments?: IComment[];
116
- initialCommentAnchors?: SerializedCommentAnchor[];
117
107
  setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
118
108
  onCommentReply?: (activeCommentId: string, reply: IComment) => void;
119
109
  onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
@@ -38,5 +38,4 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHis
38
38
  activeCommentId: string | null;
39
39
  setActiveCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
40
40
  focusCommentWithActiveId: (id: string) => void;
41
- commentAnchorsRef: import('react').MutableRefObject<import('./extensions/comment/comment-decoration-plugin').CommentAnchor[]>;
42
41
  };