@fileverse-dev/ddoc 3.0.79-skeleton-2 → 3.0.79-zustand-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.
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ import { CommentStoreExternalDeps } from './comment-store';
3
+
4
+ export interface CommentStoreProviderProps extends CommentStoreExternalDeps {
5
+ children: React.ReactNode;
6
+ }
7
+ /**
8
+ * Thin provider that:
9
+ * 1. Creates a per-mount store instance
10
+ * 2. Syncs React props into the store on every render
11
+ * 3. Manages DOM refs (not in Zustand — refs are React concerns)
12
+ * 4. Handles click-outside for comment dropdown
13
+ */
14
+ export declare const CommentStoreProvider: ({ children, ...props }: CommentStoreProviderProps) => import("react/jsx-runtime").JSX.Element;
15
+ interface CommentRefsContextType {
16
+ commentsSectionRef: React.RefObject<HTMLDivElement>;
17
+ replySectionRef: React.RefObject<HTMLDivElement>;
18
+ portalRef: React.RefObject<HTMLDivElement>;
19
+ buttonRef: React.RefObject<HTMLDivElement>;
20
+ dropdownRef: React.RefObject<HTMLDivElement>;
21
+ }
22
+ export declare const useCommentRefs: () => CommentRefsContextType;
23
+ export {};
@@ -0,0 +1,112 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { IComment } from '../extensions/comment';
3
+ import { CommentMutationMeta, CommentMutationType } from '../types';
4
+ import { EnsCache } from '../components/inline-comment/context/types';
5
+ import { EnsStatus } from '../components/inline-comment/types';
6
+
7
+ import * as Y from 'yjs';
8
+ export interface CommentStoreState {
9
+ editor: Editor | null;
10
+ ydoc: Y.Doc | null;
11
+ initialComments: IComment[];
12
+ username: string | null;
13
+ activeCommentId: string | null;
14
+ activeTabId: string;
15
+ ensResolutionUrl: string;
16
+ isConnected: boolean;
17
+ isLoading: boolean;
18
+ isDDocOwner: boolean;
19
+ setUsername: ((name: string) => void) | null;
20
+ setInitialComments: ((comments: IComment[]) => void) | null;
21
+ setActiveCommentId: ((id: string | null) => void) | null;
22
+ focusCommentWithActiveId: ((id: string) => void) | null;
23
+ onNewComment: ((comment: IComment, meta?: CommentMutationMeta) => void) | null;
24
+ onCommentReply: ((activeCommentId: string, reply: IComment) => void) | null;
25
+ onResolveComment: ((commentId: string, meta?: CommentMutationMeta) => void) | null;
26
+ onUnresolveComment: ((commentId: string, meta?: CommentMutationMeta) => void) | null;
27
+ onDeleteComment: ((commentId: string, meta?: CommentMutationMeta) => void) | null;
28
+ onInlineComment: (() => void) | null;
29
+ onComment: (() => void) | null;
30
+ setCommentDrawerOpen: ((open: boolean) => void) | null;
31
+ connectViaWallet: (() => Promise<void>) | null;
32
+ connectViaUsername: ((username: string) => Promise<void>) | null;
33
+ showResolved: boolean;
34
+ reply: string;
35
+ comment: string;
36
+ openReplyId: string | null;
37
+ selectedText: string;
38
+ isCommentOpen: boolean;
39
+ isBubbleMenuSuppressed: boolean;
40
+ inlineCommentData: {
41
+ inlineCommentText: string;
42
+ handleClick: boolean;
43
+ };
44
+ ensCache: EnsCache;
45
+ inProgressFetch: string[];
46
+ getTabComments: () => IComment[];
47
+ getActiveComment: () => IComment | undefined;
48
+ getActiveComments: () => IComment[];
49
+ getActiveCommentIndex: () => number;
50
+ getIsCommentActive: () => boolean;
51
+ getIsCommentResolved: () => boolean;
52
+ setShowResolved: (show: boolean) => void;
53
+ setReply: (reply: string) => void;
54
+ setComment: (comment: string) => void;
55
+ setOpenReplyId: (id: string | null) => void;
56
+ setSelectedText: (text: string) => void;
57
+ setIsCommentOpen: (open: boolean) => void;
58
+ setIsBubbleMenuSuppressed: (suppressed: boolean) => void;
59
+ setInlineCommentData: (data: {
60
+ inlineCommentText: string;
61
+ handleClick: boolean;
62
+ }) => void;
63
+ toggleResolved: () => void;
64
+ handleInput: (e: React.FormEvent<HTMLTextAreaElement>, content: string) => void;
65
+ handleReplyChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
66
+ handleCommentChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
67
+ addComment: (content?: string, usernameProp?: string) => string | undefined;
68
+ resolveComment: (commentId: string) => void;
69
+ unresolveComment: (commentId: string) => void;
70
+ deleteComment: (commentId: string) => void;
71
+ handleAddReply: (activeCommentId: string, replyContent: string, replyCallback?: (activeCommentId: string, reply: IComment) => void) => void;
72
+ handleCommentSubmit: () => void;
73
+ handleCommentKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
74
+ handleReplySubmit: () => void;
75
+ handleReplyKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
76
+ handleInlineComment: () => void;
77
+ focusCommentInEditor: (commentId: string) => void;
78
+ onPrevComment: () => void;
79
+ onNextComment: () => void;
80
+ getEnsStatus: (walletAddress: string, setEnsStatus: React.Dispatch<React.SetStateAction<EnsStatus>>) => void;
81
+ createMutationMeta: (type: CommentMutationType, mutate: () => boolean) => CommentMutationMeta | undefined;
82
+ syncExternalDeps: (props: CommentStoreExternalDeps) => void;
83
+ }
84
+ export interface CommentStoreExternalDeps {
85
+ editor: Editor;
86
+ ydoc: Y.Doc;
87
+ initialComments: IComment[];
88
+ username: string | null;
89
+ activeCommentId: string | null;
90
+ activeTabId: string;
91
+ ensResolutionUrl: string;
92
+ isConnected?: boolean;
93
+ isLoading?: boolean;
94
+ isDDocOwner?: boolean;
95
+ setUsername?: (name: string) => void;
96
+ setInitialComments?: (comments: IComment[]) => void;
97
+ setActiveCommentId: (id: string | null) => void;
98
+ focusCommentWithActiveId: (id: string) => void;
99
+ onNewComment?: (comment: IComment, meta?: CommentMutationMeta) => void;
100
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
101
+ onResolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
102
+ onUnresolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
103
+ onDeleteComment?: (commentId: string, meta?: CommentMutationMeta) => void;
104
+ onInlineComment?: () => void;
105
+ onComment?: () => void;
106
+ setCommentDrawerOpen?: (open: boolean) => void;
107
+ connectViaWallet?: () => Promise<void>;
108
+ connectViaUsername?: (username: string) => Promise<void>;
109
+ }
110
+ export declare const createCommentStore: () => import('zustand').StoreApi<CommentStoreState>;
111
+ export declare const CommentStoreContext: import('react').Context<import('zustand').StoreApi<CommentStoreState> | null>;
112
+ export declare function useCommentStore<T>(selector: (state: CommentStoreState) => T): T;