@fileverse-dev/ddoc 3.0.96-zustand-2 → 3.0.96-zustand-3
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.
- package/dist/index.es.js +15735 -15657
- package/dist/package/stores/comment-store-provider.d.ts +30 -10
- package/dist/package/stores/comment-store.d.ts +48 -46
- package/package.json +1 -1
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { IComment } from '../extensions/comment';
|
|
3
|
+
import { CommentMutationMeta } from '../types';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
import * as Y from 'yjs';
|
|
7
|
+
export interface CommentStoreProviderProps {
|
|
5
8
|
children: React.ReactNode;
|
|
9
|
+
editor: Editor | null;
|
|
10
|
+
ydoc: Y.Doc;
|
|
11
|
+
setActiveCommentId: (id: string | null) => void;
|
|
12
|
+
focusCommentWithActiveId: (id: string) => void;
|
|
13
|
+
setInitialComments?: (comments: IComment[]) => void;
|
|
14
|
+
onNewComment?: (comment: IComment, meta?: CommentMutationMeta) => void;
|
|
15
|
+
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
16
|
+
onResolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
17
|
+
onUnresolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
18
|
+
onDeleteComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
19
|
+
onInlineComment?: () => void;
|
|
20
|
+
onComment?: () => void;
|
|
21
|
+
setCommentDrawerOpen?: (open: boolean) => void;
|
|
22
|
+
connectViaWallet?: () => Promise<void>;
|
|
23
|
+
connectViaUsername?: (username: string) => Promise<void>;
|
|
24
|
+
ensResolutionUrl: string;
|
|
25
|
+
initialComments: IComment[];
|
|
26
|
+
username: string | null;
|
|
27
|
+
activeCommentId: string | null;
|
|
28
|
+
activeTabId: string;
|
|
29
|
+
isConnected?: boolean;
|
|
30
|
+
isLoading?: boolean;
|
|
31
|
+
isDDocOwner?: boolean;
|
|
32
|
+
setUsername?: (name: string) => void;
|
|
6
33
|
}
|
|
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;
|
|
34
|
+
export declare const CommentStoreProvider: ({ children, editor, ydoc, setActiveCommentId, focusCommentWithActiveId, setInitialComments, onNewComment, onCommentReply, onResolveComment, onUnresolveComment, onDeleteComment, onInlineComment, onComment, setCommentDrawerOpen, connectViaWallet, connectViaUsername, ensResolutionUrl, setUsername: setUsernameProp, initialComments, username, activeCommentId, activeTabId, isConnected, isLoading, isDDocOwner, }: CommentStoreProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
35
|
interface CommentRefsContextType {
|
|
16
36
|
commentsSectionRef: React.RefObject<HTMLDivElement>;
|
|
17
37
|
replySectionRef: React.RefObject<HTMLDivElement>;
|
|
@@ -3,33 +3,46 @@ import { IComment } from '../extensions/comment';
|
|
|
3
3
|
import { CommentMutationMeta, CommentMutationType } from '../types';
|
|
4
4
|
import { EnsCache } from '../components/inline-comment/context/types';
|
|
5
5
|
import { EnsStatus } from '../components/inline-comment/types';
|
|
6
|
+
import { default as React } from 'react';
|
|
6
7
|
|
|
7
8
|
import * as Y from 'yjs';
|
|
8
|
-
export interface
|
|
9
|
+
export interface CommentExternalDeps {
|
|
9
10
|
editor: Editor | null;
|
|
10
|
-
ydoc: Y.Doc
|
|
11
|
+
ydoc: Y.Doc;
|
|
12
|
+
setActiveCommentId: (id: string | null) => void;
|
|
13
|
+
focusCommentWithActiveId: (id: string) => void;
|
|
14
|
+
setInitialComments?: (comments: IComment[]) => void;
|
|
15
|
+
setUsername?: (name: string) => void;
|
|
16
|
+
onNewComment?: (comment: IComment, meta?: CommentMutationMeta) => void;
|
|
17
|
+
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
18
|
+
onResolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
19
|
+
onUnresolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
20
|
+
onDeleteComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
21
|
+
onInlineComment?: () => void;
|
|
22
|
+
onComment?: () => void;
|
|
23
|
+
setCommentDrawerOpen?: (open: boolean) => void;
|
|
24
|
+
connectViaWallet?: () => Promise<void>;
|
|
25
|
+
connectViaUsername?: (username: string) => Promise<void>;
|
|
26
|
+
ensResolutionUrl: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CommentStoreState {
|
|
11
29
|
initialComments: IComment[];
|
|
30
|
+
tabComments: IComment[];
|
|
31
|
+
activeComments: IComment[];
|
|
32
|
+
activeComment: IComment | undefined;
|
|
33
|
+
activeCommentIndex: number;
|
|
12
34
|
username: string | null;
|
|
13
35
|
activeCommentId: string | null;
|
|
14
36
|
activeTabId: string;
|
|
15
|
-
ensResolutionUrl: string;
|
|
16
37
|
isConnected: boolean;
|
|
17
38
|
isLoading: boolean;
|
|
18
39
|
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
40
|
onComment: (() => void) | null;
|
|
30
41
|
setCommentDrawerOpen: ((open: boolean) => void) | null;
|
|
31
42
|
connectViaWallet: (() => Promise<void>) | null;
|
|
32
43
|
connectViaUsername: ((username: string) => Promise<void>) | null;
|
|
44
|
+
isCommentActive: boolean;
|
|
45
|
+
isCommentResolved: boolean;
|
|
33
46
|
showResolved: boolean;
|
|
34
47
|
reply: string;
|
|
35
48
|
comment: string;
|
|
@@ -43,6 +56,22 @@ export interface CommentStoreState {
|
|
|
43
56
|
};
|
|
44
57
|
ensCache: EnsCache;
|
|
45
58
|
inProgressFetch: string[];
|
|
59
|
+
_externalDepsRef: React.RefObject<CommentExternalDeps | null> | null;
|
|
60
|
+
setExternalDepsRef: (ref: React.RefObject<CommentExternalDeps | null>) => void;
|
|
61
|
+
_recomputeDerived: () => void;
|
|
62
|
+
setInitialComments: (comments: IComment[]) => void;
|
|
63
|
+
setUsername: (username: string | null) => void;
|
|
64
|
+
setActiveCommentId: (id: string | null) => void;
|
|
65
|
+
setActiveTabId: (tabId: string) => void;
|
|
66
|
+
setIsConnected: (connected: boolean) => void;
|
|
67
|
+
setIsLoading: (loading: boolean) => void;
|
|
68
|
+
setIsDDocOwner: (isOwner: boolean) => void;
|
|
69
|
+
setOnComment: (fn: (() => void) | null) => void;
|
|
70
|
+
setCommentDrawerOpenFn: (fn: ((open: boolean) => void) | null) => void;
|
|
71
|
+
setConnectViaWallet: (fn: (() => Promise<void>) | null) => void;
|
|
72
|
+
setConnectViaUsername: (fn: ((username: string) => Promise<void>) | null) => void;
|
|
73
|
+
setIsCommentActive: (active: boolean) => void;
|
|
74
|
+
setIsCommentResolved: (resolved: boolean) => void;
|
|
46
75
|
getTabComments: () => IComment[];
|
|
47
76
|
getActiveComment: () => IComment | undefined;
|
|
48
77
|
getActiveComments: () => IComment[];
|
|
@@ -64,49 +93,22 @@ export interface CommentStoreState {
|
|
|
64
93
|
handleInput: (e: React.FormEvent<HTMLTextAreaElement>, content: string) => void;
|
|
65
94
|
handleReplyChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
66
95
|
handleCommentChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
96
|
+
handleCommentKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
97
|
+
handleReplyKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
98
|
+
handleReplySubmit: () => void;
|
|
99
|
+
handleCommentSubmit: () => void;
|
|
100
|
+
handleInlineComment: () => void;
|
|
67
101
|
addComment: (content?: string, usernameProp?: string) => string | undefined;
|
|
68
102
|
resolveComment: (commentId: string) => void;
|
|
69
103
|
unresolveComment: (commentId: string) => void;
|
|
70
104
|
deleteComment: (commentId: string) => void;
|
|
71
105
|
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
106
|
focusCommentInEditor: (commentId: string) => void;
|
|
78
107
|
onPrevComment: () => void;
|
|
79
108
|
onNextComment: () => void;
|
|
80
109
|
getEnsStatus: (walletAddress: string, setEnsStatus: React.Dispatch<React.SetStateAction<EnsStatus>>) => void;
|
|
81
110
|
createMutationMeta: (type: CommentMutationType, mutate: () => boolean) => CommentMutationMeta | undefined;
|
|
82
|
-
syncExternalDeps: (props: CommentStoreExternalDeps) => void;
|
|
83
|
-
}
|
|
84
|
-
export interface CommentStoreExternalDeps {
|
|
85
|
-
editor: Editor | null;
|
|
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
111
|
}
|
|
110
112
|
export declare const createCommentStore: () => import('zustand').StoreApi<CommentStoreState>;
|
|
111
|
-
export declare const CommentStoreContext:
|
|
113
|
+
export declare const CommentStoreContext: React.Context<import('zustand').StoreApi<CommentStoreState> | null>;
|
|
112
114
|
export declare function useCommentStore<T>(selector: (state: CommentStoreState) => T): T;
|