@fileverse-dev/ddoc 3.0.95 → 3.0.96-zustand-2
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 +21336 -21420
- package/dist/package/hooks/use-yjs-setup.d.ts +3 -2
- package/dist/package/stores/comment-store-provider.d.ts +23 -0
- package/dist/package/stores/comment-store.d.ts +112 -0
- package/dist/package/types.d.ts +1 -1
- package/dist/package/use-ddoc-editor.d.ts +1 -0
- package/package.json +5 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { JSONContent } from '@tiptap/react';
|
|
2
1
|
import { CollaborationProps } from '../sync-local/types';
|
|
2
|
+
import { DdocProps } from '../types';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
4
|
interface UseYjsSetupArgs {
|
|
5
|
-
onChange?:
|
|
5
|
+
onChange?: DdocProps['onChange'];
|
|
6
6
|
enableIndexeddbSync?: boolean;
|
|
7
7
|
ddocId?: string;
|
|
8
8
|
collaboration?: CollaborationProps;
|
|
@@ -16,6 +16,7 @@ export declare const useYjsSetup: ({ onChange, enableIndexeddbSync, ddocId, coll
|
|
|
16
16
|
terminateSession: () => void;
|
|
17
17
|
awareness: import('y-protocols/awareness.js').Awareness | null;
|
|
18
18
|
hasCollabContentInitialised: boolean;
|
|
19
|
+
isIndexeddbSynced: boolean;
|
|
19
20
|
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
20
21
|
refreshYjsIndexedDbProvider: () => Promise<void>;
|
|
21
22
|
flushPendingUpdate: () => void;
|
|
@@ -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 | 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
|
+
}
|
|
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;
|
package/dist/package/types.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
138
138
|
renderNavbar?: ({ editor }: {
|
|
139
139
|
editor: JSONContent;
|
|
140
140
|
}) => JSX.Element;
|
|
141
|
-
onChange?: (updatedDocContent:
|
|
141
|
+
onChange?: (updatedDocContent: string | JSONContent, updateChunk: string) => void;
|
|
142
142
|
onCollaboratorChange?: (collaborators: undefined | IDocCollabUsers[]) => void;
|
|
143
143
|
onTextSelection?: (data: IEditorSelectionData) => void;
|
|
144
144
|
onCommentInteraction?: (data: IEditorSelectionData) => void;
|
|
@@ -25,6 +25,7 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHis
|
|
|
25
25
|
isReady: boolean;
|
|
26
26
|
isSyncing: boolean;
|
|
27
27
|
hasCollabContentInitialised: boolean;
|
|
28
|
+
isIndexeddbSynced: boolean;
|
|
28
29
|
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
29
30
|
flushPendingUpdate: () => void;
|
|
30
31
|
collabState: import('./types').CollabState;
|
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.
|
|
5
|
+
"version": "3.0.96-zustand-2",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
8
8
|
"exports": {
|
|
@@ -93,7 +93,6 @@
|
|
|
93
93
|
"mammoth": "^1.10.0",
|
|
94
94
|
"markdown-it-footnote": "^4.0.0",
|
|
95
95
|
"ollama": "^0.5.14",
|
|
96
|
-
"socket.io-client": "^4.7.5",
|
|
97
96
|
"platform": "^1.3.6",
|
|
98
97
|
"prosemirror-model": "^1.21.0",
|
|
99
98
|
"prosemirror-state": "^1.4.3",
|
|
@@ -101,6 +100,7 @@
|
|
|
101
100
|
"react-dom": "^18.2.0",
|
|
102
101
|
"react-tweet": "^3.2.2",
|
|
103
102
|
"react-uuid": "^2.0.0",
|
|
103
|
+
"socket.io-client": "^4.7.5",
|
|
104
104
|
"tailwindcss-animate": "^1.0.7",
|
|
105
105
|
"tiptap-markdown": "^0.9.0",
|
|
106
106
|
"turndown": "^7.2.0",
|
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
"y-prosemirror": "^1.2.5",
|
|
114
114
|
"y-protocols": "^1.0.6",
|
|
115
115
|
"y-webrtc": "^10.3.0",
|
|
116
|
-
"yjs": "^13.6.15"
|
|
116
|
+
"yjs": "^13.6.15",
|
|
117
|
+
"zustand": "^5.0.12"
|
|
117
118
|
},
|
|
118
119
|
"peerDependencies": {
|
|
119
120
|
"@dnd-kit/core": ">=6.3.1",
|
|
@@ -152,4 +153,4 @@
|
|
|
152
153
|
"typescript": "^5.2.2",
|
|
153
154
|
"vite": "^5.0.0"
|
|
154
155
|
}
|
|
155
|
-
}
|
|
156
|
+
}
|