@fileverse-dev/ddoc 3.1.7-linkCaption-0 → 3.1.7-sg-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.
- package/dist/index.es.js +35271 -30419
- package/dist/package/components/editor-bubble-menu/props.d.ts +2 -0
- package/dist/package/components/inline-comment/comment-card.d.ts +1 -1
- package/dist/package/components/inline-comment/comment-drawer.d.ts +1 -1
- package/dist/package/components/inline-comment/comment-dropdown.d.ts +1 -1
- package/dist/package/components/inline-comment/comment-floating-container.d.ts +1 -0
- package/dist/package/components/inline-comment/comment-floating-layout.d.ts +34 -0
- package/dist/package/components/inline-comment/comment-input-field.d.ts +4 -0
- package/dist/package/components/inline-comment/comment-reply-input.d.ts +8 -0
- package/dist/package/components/inline-comment/comment-section.d.ts +1 -1
- package/dist/package/components/inline-comment/comment-username.d.ts +1 -1
- package/dist/package/components/inline-comment/constants.d.ts +1 -0
- package/dist/package/components/inline-comment/context/types.d.ts +52 -89
- package/dist/package/components/inline-comment/delete-confirm-overlay.d.ts +10 -0
- package/dist/package/components/inline-comment/empty-comments.d.ts +4 -1
- package/dist/package/components/inline-comment/floating-comment/comment-floating-container.d.ts +3 -0
- package/dist/package/components/inline-comment/floating-comment/draft-floating-card.d.ts +3 -0
- package/dist/package/components/inline-comment/floating-comment/floating-auth-prompt.d.ts +1 -0
- package/dist/package/components/inline-comment/floating-comment/floating-card-shell.d.ts +3 -0
- package/dist/package/components/inline-comment/floating-comment/index.d.ts +1 -0
- package/dist/package/components/inline-comment/floating-comment/suggestion-draft-floating-card.d.ts +11 -0
- package/dist/package/components/inline-comment/floating-comment/suggestion-thread-floating-card.d.ts +15 -0
- package/dist/package/components/inline-comment/floating-comment/thread-floating-card.d.ts +3 -0
- package/dist/package/components/inline-comment/floating-comment/types.d.ts +39 -0
- package/dist/package/components/inline-comment/floating-comment-layout-utils.d.ts +81 -0
- package/dist/package/components/inline-comment/resize-inline-comment-textarea.d.ts +1 -0
- package/dist/package/components/inline-comment/types.d.ts +24 -0
- package/dist/package/components/inline-comment/use-anchor-registry.d.ts +34 -0
- package/dist/package/components/inline-comment/use-comment-card.d.ts +29 -0
- package/dist/package/components/inline-comment/use-comment-list-container.d.ts +17 -0
- package/dist/package/components/inline-comment/use-ens-status.d.ts +3 -0
- package/dist/package/components/inline-comment/use-floating-card-state.d.ts +36 -0
- package/dist/package/components/inline-comment/use-floating-comment-card-layout.d.ts +23 -0
- package/dist/package/components/inline-comment/use-floating-comment-card-state.d.ts +13 -0
- package/dist/package/components/inline-comment/use-floating-layout-engine.d.ts +26 -0
- package/dist/package/components/inline-comment/use-is-selected-content-deleted.d.ts +1 -0
- package/dist/package/components/tabs/document-tabs-sidebar.d.ts +2 -1
- package/dist/package/extensions/comment/comment-decoration-plugin.d.ts +95 -0
- package/dist/package/extensions/comment/comment.d.ts +38 -0
- package/dist/package/extensions/resizable-media/resizable-media-menu-util.d.ts +5 -4
- package/dist/package/extensions/resizable-media/resizable-media-node-view.d.ts +1 -1
- package/dist/package/extensions/suggestion/suggestion-tracking-extension.d.ts +30 -0
- package/dist/package/hooks/use-editing-context.d.ts +2 -0
- package/dist/package/hooks/use-tab-editor.d.ts +9 -2
- package/dist/package/stores/comment-store-provider.d.ts +64 -0
- package/dist/package/stores/comment-store.d.ts +263 -0
- package/dist/package/types.d.ts +25 -2
- package/dist/package/use-ddoc-editor.d.ts +6 -1
- package/dist/package/utils/comment-anchor-serialization.d.ts +5 -0
- package/dist/package/utils/comment-scroll-into-view.d.ts +21 -0
- package/dist/style.css +1 -1
- package/package.json +4 -3
- package/dist/package/components/inline-comment/context/comment-context.d.ts +0 -4
- package/dist/package/extensions/resizable-media/media-caption.d.ts +0 -3
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
|
|
4
|
+
import { CommentFloatingCard, EnsCache, InlineCommentData, InlineCommentDraft, InlineDraftLocation } from '../components/inline-comment/context/types';
|
|
5
|
+
import { EnsStatus } from '../components/inline-comment/types';
|
|
6
|
+
import { IComment } from '../extensions/comment';
|
|
7
|
+
import { CommentMutationMeta, CommentMutationType } from '../types';
|
|
8
|
+
|
|
9
|
+
import * as Y from 'yjs';
|
|
10
|
+
export interface CommentExternalDeps {
|
|
11
|
+
editor: Editor | null;
|
|
12
|
+
ydoc: Y.Doc;
|
|
13
|
+
setActiveCommentId: (id: string | null) => void;
|
|
14
|
+
focusCommentWithActiveId: (id: string) => void;
|
|
15
|
+
setInitialComments?: React.Dispatch<React.SetStateAction<IComment[]>>;
|
|
16
|
+
setUsername?: React.Dispatch<React.SetStateAction<string>>;
|
|
17
|
+
onNewComment?: (comment: IComment, meta?: CommentMutationMeta) => void;
|
|
18
|
+
onEditComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
19
|
+
onEditReply?: (commentId: string, replyId: string, meta?: CommentMutationMeta) => void;
|
|
20
|
+
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
21
|
+
onResolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
22
|
+
onUnresolveComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
23
|
+
onDeleteComment?: (commentId: string, meta?: CommentMutationMeta) => void;
|
|
24
|
+
onInlineComment?: () => void;
|
|
25
|
+
onComment?: () => void;
|
|
26
|
+
setCommentDrawerOpen?: (open: boolean) => void;
|
|
27
|
+
connectViaWallet?: () => Promise<void>;
|
|
28
|
+
connectViaUsername?: (username: string) => Promise<void>;
|
|
29
|
+
ensResolutionUrl: string;
|
|
30
|
+
commentAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
|
|
31
|
+
refreshCommentAnchorState?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Derived anchor list for in-progress suggestion drafts. Maintained by the
|
|
34
|
+
* store (not the consumer) — draft actions upsert into this ref whenever
|
|
35
|
+
* state.drafts changes. The decoration extension reads this ref alongside
|
|
36
|
+
* commentAnchorsRef to render both layers identically.
|
|
37
|
+
*/
|
|
38
|
+
draftAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A suggestion draft is the viewer's in-progress proposed edit — kept local
|
|
42
|
+
* until Submit. Drafts live in memory only (lost on refresh). Derived into
|
|
43
|
+
* a CommentAnchor for decoration rendering via deriveDraftAnchor(). The
|
|
44
|
+
* suggestion type ('add' | 'delete' | 'replace') is not stored; it is derived
|
|
45
|
+
* at use time from hadDeletion + insertedText.
|
|
46
|
+
*/
|
|
47
|
+
export interface DraftSuggestion {
|
|
48
|
+
id: string;
|
|
49
|
+
anchorFrom: Y.RelativePosition;
|
|
50
|
+
anchorTo: Y.RelativePosition;
|
|
51
|
+
/** The text that was selected at draft creation (for Delete/Replace strikethrough). */
|
|
52
|
+
originalContent: string;
|
|
53
|
+
/** Accumulated text the viewer has typed. Empty for a pure Delete draft. */
|
|
54
|
+
insertedText: string;
|
|
55
|
+
/** Per-keystroke history for undo — each entry is one typed character. */
|
|
56
|
+
keystrokes: string[];
|
|
57
|
+
/** True when the draft was created via select+delete or select+type. */
|
|
58
|
+
hadDeletion: boolean;
|
|
59
|
+
}
|
|
60
|
+
type FloatingCardsUpdater = React.SetStateAction<CommentFloatingCard[]>;
|
|
61
|
+
type InlineCommentDataUpdater = Partial<InlineCommentData> | ((prev: InlineCommentData) => Partial<InlineCommentData> | InlineCommentData);
|
|
62
|
+
type InlineDraftRecordMap = Record<string, InlineCommentDraft>;
|
|
63
|
+
type CreateInlineDraftOptions = {
|
|
64
|
+
location?: InlineDraftLocation;
|
|
65
|
+
tabId?: string;
|
|
66
|
+
allowEmptySelection?: boolean;
|
|
67
|
+
};
|
|
68
|
+
type CommentEditRequest = {
|
|
69
|
+
requestId: string;
|
|
70
|
+
kind: 'comment' | 'reply';
|
|
71
|
+
commentId: string;
|
|
72
|
+
replyId?: string;
|
|
73
|
+
text: string;
|
|
74
|
+
};
|
|
75
|
+
type ReplyEditTarget = {
|
|
76
|
+
kind: 'comment' | 'reply';
|
|
77
|
+
commentId: string;
|
|
78
|
+
replyId?: string;
|
|
79
|
+
originalText: string;
|
|
80
|
+
};
|
|
81
|
+
type CommentEditCompletion = {
|
|
82
|
+
nonce: number;
|
|
83
|
+
kind: 'comment' | 'reply';
|
|
84
|
+
commentId: string;
|
|
85
|
+
replyId?: string;
|
|
86
|
+
};
|
|
87
|
+
type FocusCommentInEditorOptions = {
|
|
88
|
+
source?: 'explicit-ui' | 'passive';
|
|
89
|
+
};
|
|
90
|
+
type ReconcileFloatingThreadsForActiveTabOptions = {
|
|
91
|
+
hydrationReady: boolean;
|
|
92
|
+
};
|
|
93
|
+
export declare const EXPLICIT_COMMENT_FOCUS_META = "inlineCommentExplicitFocus";
|
|
94
|
+
export interface CommentStoreState {
|
|
95
|
+
initialComments: IComment[];
|
|
96
|
+
tabComments: IComment[];
|
|
97
|
+
activeComments: IComment[];
|
|
98
|
+
activeComment: IComment | undefined;
|
|
99
|
+
activeCommentIndex: number;
|
|
100
|
+
username: string | null;
|
|
101
|
+
activeCommentId: string | null;
|
|
102
|
+
activeTabId: string;
|
|
103
|
+
isConnected: boolean;
|
|
104
|
+
isLoading: boolean;
|
|
105
|
+
isDDocOwner: boolean;
|
|
106
|
+
onComment: (() => void) | null;
|
|
107
|
+
setCommentDrawerOpen: ((open: boolean) => void) | null;
|
|
108
|
+
connectViaWallet: (() => Promise<void>) | null;
|
|
109
|
+
connectViaUsername: ((username: string) => Promise<void>) | null;
|
|
110
|
+
isCommentActive: boolean;
|
|
111
|
+
isCommentResolved: boolean;
|
|
112
|
+
showResolved: boolean;
|
|
113
|
+
reply: string;
|
|
114
|
+
comment: string;
|
|
115
|
+
openReplyId: string | null;
|
|
116
|
+
selectedText: string;
|
|
117
|
+
isCommentOpen: boolean;
|
|
118
|
+
isBubbleMenuSuppressed: boolean;
|
|
119
|
+
inlineCommentData: InlineCommentData;
|
|
120
|
+
floatingCards: CommentFloatingCard[];
|
|
121
|
+
pendingPrehydrationFloatingThreadIds: string[];
|
|
122
|
+
/** In-progress suggestion drafts — keyed by suggestionId. Viewer-local, lost on refresh. */
|
|
123
|
+
drafts: Record<string, DraftSuggestion>;
|
|
124
|
+
/**
|
|
125
|
+
* Suggestion IDs submitted from this session. Used to show the withdraw (X)
|
|
126
|
+
* action for viewers even when they don't have a persistent username set.
|
|
127
|
+
* Session-local, lost on refresh.
|
|
128
|
+
*/
|
|
129
|
+
mySubmittedSuggestionIds: Set<string>;
|
|
130
|
+
inlineDrafts: InlineDraftRecordMap;
|
|
131
|
+
activeDraftId: string | null;
|
|
132
|
+
isDesktopFloatingEnabled: boolean;
|
|
133
|
+
ensCache: EnsCache;
|
|
134
|
+
inProgressFetch: string[];
|
|
135
|
+
editRequest: CommentEditRequest | null;
|
|
136
|
+
replyEditTarget: ReplyEditTarget | null;
|
|
137
|
+
editCompletion: CommentEditCompletion | null;
|
|
138
|
+
_externalDepsRef: React.RefObject<CommentExternalDeps | null> | null;
|
|
139
|
+
setExternalDepsRef: (ref: React.RefObject<CommentExternalDeps | null>) => void;
|
|
140
|
+
_recomputeDerived: () => void;
|
|
141
|
+
setInitialComments: (comments: IComment[]) => void;
|
|
142
|
+
setUsername: (username: string | null) => void;
|
|
143
|
+
setActiveCommentId: (id: string | null) => void;
|
|
144
|
+
setActiveTabId: (tabId: string) => void;
|
|
145
|
+
setIsConnected: (connected: boolean) => void;
|
|
146
|
+
setIsLoading: (loading: boolean) => void;
|
|
147
|
+
setIsDDocOwner: (isOwner: boolean) => void;
|
|
148
|
+
setOnComment: (fn: (() => void) | null) => void;
|
|
149
|
+
setCommentDrawerOpenFn: (fn: ((open: boolean) => void) | null) => void;
|
|
150
|
+
setConnectViaWallet: (fn: (() => Promise<void>) | null) => void;
|
|
151
|
+
setConnectViaUsername: (fn: ((username: string) => Promise<void>) | null) => void;
|
|
152
|
+
setIsCommentActive: (active: boolean) => void;
|
|
153
|
+
setIsCommentResolved: (resolved: boolean) => void;
|
|
154
|
+
getTabComments: () => IComment[];
|
|
155
|
+
getActiveComment: () => IComment | undefined;
|
|
156
|
+
getActiveComments: () => IComment[];
|
|
157
|
+
getActiveCommentIndex: () => number;
|
|
158
|
+
getIsCommentActive: () => boolean;
|
|
159
|
+
getIsCommentResolved: () => boolean;
|
|
160
|
+
setShowResolved: (show: boolean) => void;
|
|
161
|
+
setReply: (reply: string) => void;
|
|
162
|
+
setComment: (comment: string) => void;
|
|
163
|
+
setOpenReplyId: (id: string | null) => void;
|
|
164
|
+
setSelectedText: (text: string) => void;
|
|
165
|
+
setIsCommentOpen: (open: boolean) => void;
|
|
166
|
+
setIsBubbleMenuSuppressed: (suppressed: boolean) => void;
|
|
167
|
+
setInlineCommentData: (data: InlineCommentDataUpdater) => void;
|
|
168
|
+
setFloatingCards: (floatingCards: FloatingCardsUpdater) => void;
|
|
169
|
+
clearFloatingCards: () => void;
|
|
170
|
+
setActiveDraftId: (draftId: string | null) => void;
|
|
171
|
+
setIsDesktopFloatingEnabled: (enabled: boolean) => void;
|
|
172
|
+
toggleResolved: () => void;
|
|
173
|
+
clearEditRequest: (requestId: string) => void;
|
|
174
|
+
setReplyEditTarget: (target: ReplyEditTarget | null) => void;
|
|
175
|
+
cancelReplyEdit: () => void;
|
|
176
|
+
handleInput: (e: React.FormEvent<HTMLTextAreaElement>, content: string) => void;
|
|
177
|
+
handleReplyChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
178
|
+
handleCommentChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
179
|
+
handleCommentKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>, tabId?: string) => void;
|
|
180
|
+
handleReplyKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
181
|
+
handleReplySubmit: () => void;
|
|
182
|
+
handleCommentSubmit: (tabId?: string) => void;
|
|
183
|
+
handleInlineComment: () => void;
|
|
184
|
+
addComment: (content?: string, usernameProp?: string) => string | undefined;
|
|
185
|
+
createFloatingDraft: (options?: CreateInlineDraftOptions) => string | null;
|
|
186
|
+
updateInlineDraftText: (draftId: string, value: string) => void;
|
|
187
|
+
cancelInlineDraft: (draftId: string) => void;
|
|
188
|
+
submitInlineDraft: (draftId: string) => void;
|
|
189
|
+
updateFloatingDraftText: (draftId: string, value: string) => void;
|
|
190
|
+
cancelFloatingDraft: (draftId: string) => void;
|
|
191
|
+
submitFloatingDraft: (draftId: string) => void;
|
|
192
|
+
openFloatingThread: (commentId: string) => void;
|
|
193
|
+
closeFloatingCard: (floatingCardId: string) => void;
|
|
194
|
+
blurFloatingCard: (floatingCardId: string) => void;
|
|
195
|
+
focusFloatingCard: (floatingCardId: string) => void;
|
|
196
|
+
removeInvalidFloatingDrafts: () => void;
|
|
197
|
+
reconcileFloatingThreadsForActiveTab: (options: ReconcileFloatingThreadsForActiveTabOptions) => void;
|
|
198
|
+
syncFloatingThreadCardWithActiveComment: () => void;
|
|
199
|
+
submitPendingFloatingDrafts: () => void;
|
|
200
|
+
/**
|
|
201
|
+
* Apply anchor edits to local comment state.
|
|
202
|
+
* Called after transaction analysis identifies edited anchors.
|
|
203
|
+
* Updates selectedContent for each affected comment
|
|
204
|
+
* so thread display stays in sync immediately, before consumer rehydration.
|
|
205
|
+
*/
|
|
206
|
+
applyCommentAnchorEdits: (edits: Array<{
|
|
207
|
+
commentId: string;
|
|
208
|
+
selectedContent: string;
|
|
209
|
+
}>) => void;
|
|
210
|
+
resolveComment: (commentId: string) => void;
|
|
211
|
+
unresolveComment: (commentId: string) => void;
|
|
212
|
+
deleteComment: (commentId: string, options?: {
|
|
213
|
+
skipExternalCallback?: boolean;
|
|
214
|
+
}) => void;
|
|
215
|
+
acceptSuggestion: (commentId: string) => void;
|
|
216
|
+
/**
|
|
217
|
+
* Append typed characters to the draft at the current cursor position.
|
|
218
|
+
* Creates a new Add draft if no draft exists at the cursor.
|
|
219
|
+
*/
|
|
220
|
+
appendToDraftAtCursor: (text: string) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Create a Delete (or pending Replace) draft from a selection range.
|
|
223
|
+
* Captures originalContent, leaves insertedText empty; type becomes 'replace'
|
|
224
|
+
* as soon as the viewer types.
|
|
225
|
+
*/
|
|
226
|
+
startDeleteDraft: (from: number, to: number) => void;
|
|
227
|
+
/**
|
|
228
|
+
* Undo the last keystroke in the draft at the current cursor position.
|
|
229
|
+
* When the draft has no keystrokes left, it is discarded.
|
|
230
|
+
* For a pure Delete draft (no keystrokes ever), calling this discards.
|
|
231
|
+
*/
|
|
232
|
+
undoLastKeystrokeInActiveDraft: () => void;
|
|
233
|
+
/** Drop a draft entirely — removes the inline overlay and draft card. */
|
|
234
|
+
discardDraft: (suggestionId: string) => void;
|
|
235
|
+
/**
|
|
236
|
+
* Refresh the `originalContent` (and the suggestion-draft card's selectedText)
|
|
237
|
+
* for a Delete/Replace draft whose anchored range still resolves but now
|
|
238
|
+
* covers different text — happens when the owner edits within the anchored
|
|
239
|
+
* range while the viewer's draft is open.
|
|
240
|
+
*/
|
|
241
|
+
refreshDraftOriginalContent: (suggestionId: string, currentText: string) => void;
|
|
242
|
+
/**
|
|
243
|
+
* Promote a draft to a submitted suggestion. Pushes the anchor into
|
|
244
|
+
* commentAnchorsRef, calls onNewComment, removes the draft, and swaps the
|
|
245
|
+
* suggestion-draft floating card for a thread card (same floatingCardId).
|
|
246
|
+
*/
|
|
247
|
+
submitDraft: (suggestionId: string) => void;
|
|
248
|
+
deleteReply: (commentId: string, replyId: string) => void;
|
|
249
|
+
requestEditComment: (commentId: string) => void;
|
|
250
|
+
requestEditReply: (commentId: string, replyId: string) => void;
|
|
251
|
+
editCommentContent: (commentId: string, content: string) => void;
|
|
252
|
+
editReplyContent: (commentId: string, replyId: string, content: string) => void;
|
|
253
|
+
handleAddReply: (activeCommentId: string, replyContent: string, replyCallback?: (activeCommentId: string, reply: IComment) => void) => void;
|
|
254
|
+
focusCommentInEditor: (commentId: string, options?: FocusCommentInEditorOptions) => void;
|
|
255
|
+
onPrevComment: () => void;
|
|
256
|
+
onNextComment: () => void;
|
|
257
|
+
getEnsStatus: (walletAddress: string, setEnsStatus: React.Dispatch<React.SetStateAction<EnsStatus>>) => void;
|
|
258
|
+
createMutationMeta: (type: CommentMutationType, mutate: () => boolean) => CommentMutationMeta | undefined;
|
|
259
|
+
}
|
|
260
|
+
export declare const createCommentStore: () => import('zustand').StoreApi<CommentStoreState>;
|
|
261
|
+
export declare const CommentStoreContext: React.Context<import('zustand').StoreApi<CommentStoreState> | null>;
|
|
262
|
+
export declare function useCommentStore<T>(selector: (state: CommentStoreState) => T): T;
|
|
263
|
+
export {};
|
package/dist/package/types.d.ts
CHANGED
|
@@ -19,10 +19,29 @@ export type InlineCommentData = {
|
|
|
19
19
|
highlightedTextContent: string;
|
|
20
20
|
handleClick: boolean;
|
|
21
21
|
};
|
|
22
|
-
export type CommentMutationType = 'create' | 'resolve' | 'unresolve' | 'delete';
|
|
22
|
+
export type CommentMutationType = 'create' | 'edit' | 'resolve' | 'unresolve' | 'delete';
|
|
23
|
+
export type SuggestionType = 'add' | 'replace' | 'delete';
|
|
23
24
|
export interface CommentMutationMeta {
|
|
24
25
|
type: CommentMutationType;
|
|
25
|
-
updateChunk
|
|
26
|
+
updateChunk?: string;
|
|
27
|
+
anchorFrom?: string;
|
|
28
|
+
anchorTo?: string;
|
|
29
|
+
selectedContent?: string;
|
|
30
|
+
content?: string;
|
|
31
|
+
suggestionType?: SuggestionType;
|
|
32
|
+
originalContent?: string;
|
|
33
|
+
suggestedContent?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SerializedCommentAnchor {
|
|
36
|
+
id: string;
|
|
37
|
+
anchorFrom: string;
|
|
38
|
+
anchorTo: string;
|
|
39
|
+
resolved: boolean;
|
|
40
|
+
deleted: boolean;
|
|
41
|
+
isSuggestion?: boolean;
|
|
42
|
+
suggestionType?: SuggestionType;
|
|
43
|
+
originalContent?: string;
|
|
44
|
+
suggestedContent?: string;
|
|
26
45
|
}
|
|
27
46
|
export interface CommentAccountProps {
|
|
28
47
|
isConnected?: boolean;
|
|
@@ -107,9 +126,12 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
107
126
|
commentDrawerOpen?: boolean;
|
|
108
127
|
setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
|
|
109
128
|
initialComments?: IComment[];
|
|
129
|
+
initialCommentAnchors?: SerializedCommentAnchor[];
|
|
110
130
|
setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
|
|
111
131
|
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
112
132
|
onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
|
|
133
|
+
onEditComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
134
|
+
onEditReply?: (activeCommentId: string, replyId: string, meta?: CommentMutationMeta) => void;
|
|
113
135
|
onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
114
136
|
onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
115
137
|
onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
@@ -130,6 +152,7 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
130
152
|
editorCanvasClassNames?: string;
|
|
131
153
|
isCommentSectionOpen?: boolean;
|
|
132
154
|
isPreviewMode: boolean;
|
|
155
|
+
viewerMode?: 'suggest' | 'view-only';
|
|
133
156
|
ensResolutionUrl?: string;
|
|
134
157
|
ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
|
|
135
158
|
enableIndexeddbSync?: boolean;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DdocProps } from './types';
|
|
2
2
|
import { Editor } from '@tiptap/react';
|
|
3
3
|
|
|
4
|
-
export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHistoryState, collaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setPageCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, ...rest }: Partial<DdocProps>
|
|
4
|
+
export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent, versionHistoryState, collaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setPageCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, ...rest }: Partial<DdocProps> & {
|
|
5
|
+
isFocusMode?: boolean;
|
|
6
|
+
}) => {
|
|
5
7
|
ydoc: import('yjs').Doc;
|
|
6
8
|
awareness: import('y-protocols/awareness.js').Awareness | null;
|
|
7
9
|
refreshYjsIndexedDbProvider: () => Promise<void>;
|
|
@@ -38,4 +40,7 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHis
|
|
|
38
40
|
activeCommentId: string | null;
|
|
39
41
|
setActiveCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
40
42
|
focusCommentWithActiveId: (id: string) => void;
|
|
43
|
+
commentAnchorsRef: import('react').MutableRefObject<import('./extensions/comment/comment-decoration-plugin').CommentAnchor[]>;
|
|
44
|
+
draftAnchorsRef: import('react').MutableRefObject<import('./extensions/comment/comment-decoration-plugin').CommentAnchor[]>;
|
|
45
|
+
storeApiRef: import('react').MutableRefObject<import('zustand').StoreApi<import('./stores/comment-store').CommentStoreState> | null>;
|
|
41
46
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
|
|
2
|
+
import { SerializedCommentAnchor } from '../types';
|
|
3
|
+
|
|
4
|
+
export declare const getSerializedCommentAnchorsKey: (anchors?: SerializedCommentAnchor[]) => string | null;
|
|
5
|
+
export declare const deserializeCommentAnchors: (anchors?: SerializedCommentAnchor[]) => CommentAnchor[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
|
|
4
|
+
|
|
5
|
+
export declare const MOBILE_COMMENT_DRAWER_CANVAS_OFFSET_VAR = "--mobile-comment-drawer-canvas-offset";
|
|
6
|
+
type CommentSelectionRange = {
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const clearMobileCommentDrawerCanvasOffset: (editorRoot?: HTMLElement | null) => void;
|
|
11
|
+
export declare const resolveCommentSelectionRange: ({ editor, commentId, commentAnchorsRef, }: {
|
|
12
|
+
editor: Editor;
|
|
13
|
+
commentId: string;
|
|
14
|
+
commentAnchorsRef?: MutableRefObject<CommentAnchor[]>;
|
|
15
|
+
}) => CommentSelectionRange | null;
|
|
16
|
+
export declare const scrollCommentSelectionRangeIntoView: ({ editor, selectionRange, behavior, }: {
|
|
17
|
+
editor: Editor;
|
|
18
|
+
selectionRange: CommentSelectionRange;
|
|
19
|
+
behavior?: ScrollBehavior;
|
|
20
|
+
}) => void;
|
|
21
|
+
export {};
|