@fileverse-dev/ddoc 3.2.5-patch-2 → 3.2.6-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 +28446 -26667
- package/dist/package/components/inline-comment/comment-card.d.ts +19 -1
- package/dist/package/components/inline-comment/comment-drawer-constants.d.ts +1 -0
- package/dist/package/components/inline-comment/comment-drawer-desktop.d.ts +35 -0
- package/dist/package/components/inline-comment/comment-drawer-mobile.d.ts +43 -0
- package/dist/package/components/inline-comment/context/types.d.ts +7 -1
- package/dist/package/components/inline-comment/floating-comment/suggestion-draft-floating-card.d.ts +17 -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/types.d.ts +6 -1
- package/dist/package/components/inline-comment/floating-comment-layout-utils.d.ts +4 -1
- package/dist/package/components/inline-comment/mobile-inline-comment-sheet.d.ts +15 -0
- package/dist/package/components/inline-comment/mobile-suggestion-draft-sheet.d.ts +15 -0
- package/dist/package/components/inline-comment/types.d.ts +1 -0
- package/dist/package/components/inline-comment/use-comment-drawer-drafts.d.ts +22 -0
- package/dist/package/components/inline-comment/use-comment-drawer-filters.d.ts +40 -0
- package/dist/package/components/inline-comment/use-comment-drawer-focus.d.ts +17 -0
- package/dist/package/components/inline-comment/use-comment-drawer-lifecycle.d.ts +13 -0
- package/dist/package/components/inline-comment/use-mobile-comment-navigation.d.ts +20 -0
- package/dist/package/extensions/comment/comment-decoration-plugin.d.ts +25 -0
- package/dist/package/extensions/comment/comment.d.ts +5 -0
- package/dist/package/extensions/suggestion/suggestion-tracking-extension.d.ts +43 -0
- package/dist/package/hooks/use-editing-context.d.ts +2 -0
- package/dist/package/hooks/use-tab-editor.d.ts +4 -1
- package/dist/package/stores/comment-store-provider.d.ts +9 -1
- package/dist/package/stores/comment-store.d.ts +75 -0
- package/dist/package/types.d.ts +9 -0
- package/dist/package/use-ddoc-editor.d.ts +3 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -30,7 +30,35 @@ export interface CommentExternalDeps {
|
|
|
30
30
|
ensResolutionUrl: string;
|
|
31
31
|
commentAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
|
|
32
32
|
refreshCommentAnchorState?: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Derived anchor list for in-progress suggestion drafts. Maintained by the
|
|
35
|
+
* store (not the consumer) — draft actions upsert into this ref whenever
|
|
36
|
+
* state.drafts changes. The decoration extension reads this ref alongside
|
|
37
|
+
* commentAnchorsRef to render both layers identically.
|
|
38
|
+
*/
|
|
39
|
+
draftAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A suggestion draft is the viewer's in-progress proposed edit — kept local
|
|
43
|
+
* until Submit. Drafts live in memory only (lost on refresh). Derived into
|
|
44
|
+
* a CommentAnchor for decoration rendering via deriveDraftAnchor(). The
|
|
45
|
+
* suggestion type ('add' | 'delete' | 'replace') is not stored; it is derived
|
|
46
|
+
* at use time from hadDeletion + insertedText.
|
|
47
|
+
*/
|
|
48
|
+
export interface DraftSuggestion {
|
|
49
|
+
id: string;
|
|
50
|
+
anchorFrom: Y.RelativePosition;
|
|
51
|
+
anchorTo: Y.RelativePosition;
|
|
52
|
+
/** The text that was selected at draft creation (for Delete/Replace strikethrough). */
|
|
53
|
+
originalContent: string;
|
|
54
|
+
/** Accumulated text the viewer has typed. Empty for a pure Delete draft. */
|
|
55
|
+
insertedText: string;
|
|
56
|
+
/** Per-keystroke history for undo — each entry is one typed character. */
|
|
57
|
+
keystrokes: string[];
|
|
58
|
+
/** True when the draft was created via select+delete or select+type. */
|
|
59
|
+
hadDeletion: boolean;
|
|
33
60
|
}
|
|
61
|
+
type SuggestionDeleteDirection = 'backward' | 'forward';
|
|
34
62
|
type FloatingCardsUpdater = React.SetStateAction<CommentFloatingCard[]>;
|
|
35
63
|
type InlineCommentDataUpdater = Partial<InlineCommentData> | ((prev: InlineCommentData) => Partial<InlineCommentData> | InlineCommentData);
|
|
36
64
|
type InlineDraftRecordMap = Record<string, InlineCommentDraft>;
|
|
@@ -93,6 +121,8 @@ export interface CommentStoreState {
|
|
|
93
121
|
inlineCommentData: InlineCommentData;
|
|
94
122
|
floatingCards: CommentFloatingCard[];
|
|
95
123
|
pendingPrehydrationFloatingThreadIds: string[];
|
|
124
|
+
/** In-progress suggestion drafts — keyed by suggestionId. Viewer-local, lost on refresh. */
|
|
125
|
+
drafts: Record<string, DraftSuggestion>;
|
|
96
126
|
inlineDrafts: InlineDraftRecordMap;
|
|
97
127
|
activeDraftId: string | null;
|
|
98
128
|
isDesktopFloatingEnabled: boolean;
|
|
@@ -178,6 +208,50 @@ export interface CommentStoreState {
|
|
|
178
208
|
deleteComment: (commentId: string, options?: {
|
|
179
209
|
skipExternalCallback?: boolean;
|
|
180
210
|
}) => void;
|
|
211
|
+
acceptSuggestion: (commentId: string) => void;
|
|
212
|
+
/**
|
|
213
|
+
* Append typed characters to the draft at the current cursor position.
|
|
214
|
+
* Creates a new Add draft if no draft exists at the cursor.
|
|
215
|
+
*/
|
|
216
|
+
appendToDraftAtCursor: (text: string) => void;
|
|
217
|
+
/**
|
|
218
|
+
* Create a Delete (or pending Replace) draft from a selection range.
|
|
219
|
+
* Captures originalContent, leaves insertedText empty; type becomes 'replace'
|
|
220
|
+
* as soon as the viewer types.
|
|
221
|
+
*/
|
|
222
|
+
startDeleteDraft: (from: number, to: number, collapseTo?: number) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Convert a collapsed-caret Backspace/Delete into a delete draft when the
|
|
225
|
+
* caret is adjacent to text, or shrink the active draft if the caret is
|
|
226
|
+
* already inside one.
|
|
227
|
+
*/
|
|
228
|
+
deleteAtCursorOrUndoActiveDraft: (direction: SuggestionDeleteDirection) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Handle browser deletion paths that resolved to a concrete range even
|
|
231
|
+
* though the user had no explicit selection.
|
|
232
|
+
*/
|
|
233
|
+
deleteRangeOrUndoActiveDraft: (from: number, to: number) => void;
|
|
234
|
+
/**
|
|
235
|
+
* Undo the last keystroke in the draft at the current cursor position.
|
|
236
|
+
* When the draft has no keystrokes left, it is discarded.
|
|
237
|
+
* For a pure Delete draft (no keystrokes ever), calling this discards.
|
|
238
|
+
*/
|
|
239
|
+
undoLastKeystrokeInActiveDraft: () => void;
|
|
240
|
+
/** Drop a draft entirely — removes the inline overlay and draft card. */
|
|
241
|
+
discardDraft: (suggestionId: string) => void;
|
|
242
|
+
/**
|
|
243
|
+
* Refresh the `originalContent` (and the suggestion-draft card's selectedText)
|
|
244
|
+
* for a Delete/Replace draft whose anchored range still resolves but now
|
|
245
|
+
* covers different text — happens when the owner edits within the anchored
|
|
246
|
+
* range while the viewer's draft is open.
|
|
247
|
+
*/
|
|
248
|
+
refreshDraftOriginalContent: (suggestionId: string, currentText: string) => void;
|
|
249
|
+
/**
|
|
250
|
+
* Promote a draft to a submitted suggestion. Pushes the anchor into
|
|
251
|
+
* commentAnchorsRef, calls onNewComment, removes the draft, and swaps the
|
|
252
|
+
* suggestion-draft floating card for a thread card (same floatingCardId).
|
|
253
|
+
*/
|
|
254
|
+
submitDraft: (suggestionId: string) => void;
|
|
181
255
|
deleteReply: (commentId: string, replyId: string) => void;
|
|
182
256
|
requestEditComment: (commentId: string) => void;
|
|
183
257
|
requestEditReply: (commentId: string, replyId: string) => void;
|
|
@@ -185,6 +259,7 @@ export interface CommentStoreState {
|
|
|
185
259
|
editReplyContent: (commentId: string, replyId: string, content: string) => void;
|
|
186
260
|
handleAddReply: (activeCommentId: string, replyContent: string, replyCallback?: (activeCommentId: string, reply: IComment) => void) => void;
|
|
187
261
|
focusCommentInEditor: (commentId: string, options?: FocusCommentInEditorOptions) => void;
|
|
262
|
+
focusSuggestionDraftInEditor: (suggestionId: string) => void;
|
|
188
263
|
onPrevComment: () => void;
|
|
189
264
|
onNextComment: () => void;
|
|
190
265
|
getEnsStatus: (walletAddress: string, setEnsStatus: React.Dispatch<React.SetStateAction<EnsStatus>>) => void;
|
package/dist/package/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type InlineCommentData = {
|
|
|
20
20
|
handleClick: boolean;
|
|
21
21
|
};
|
|
22
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
26
|
updateChunk?: string;
|
|
@@ -27,6 +28,9 @@ export interface CommentMutationMeta {
|
|
|
27
28
|
anchorTo?: string;
|
|
28
29
|
selectedContent?: string;
|
|
29
30
|
content?: string;
|
|
31
|
+
suggestionType?: SuggestionType;
|
|
32
|
+
originalContent?: string;
|
|
33
|
+
suggestedContent?: string;
|
|
30
34
|
}
|
|
31
35
|
export interface SerializedCommentAnchor {
|
|
32
36
|
id: string;
|
|
@@ -34,6 +38,10 @@ export interface SerializedCommentAnchor {
|
|
|
34
38
|
anchorTo: string;
|
|
35
39
|
resolved: boolean;
|
|
36
40
|
deleted: boolean;
|
|
41
|
+
isSuggestion?: boolean;
|
|
42
|
+
suggestionType?: SuggestionType;
|
|
43
|
+
originalContent?: string;
|
|
44
|
+
suggestedContent?: string;
|
|
37
45
|
}
|
|
38
46
|
export interface CommentAccountProps {
|
|
39
47
|
isConnected?: boolean;
|
|
@@ -145,6 +153,7 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
145
153
|
editorCanvasClassNames?: string;
|
|
146
154
|
isCommentSectionOpen?: boolean;
|
|
147
155
|
isPreviewMode: boolean;
|
|
156
|
+
viewerMode?: 'suggest' | 'view-only';
|
|
148
157
|
ensResolutionUrl?: string;
|
|
149
158
|
ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
|
|
150
159
|
enableIndexeddbSync?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
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, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, ...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
5
|
isFocusMode?: boolean;
|
|
6
6
|
}) => {
|
|
7
7
|
ydoc: import('yjs').Doc;
|
|
@@ -41,4 +41,6 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHis
|
|
|
41
41
|
setActiveCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
42
42
|
focusCommentWithActiveId: (id: string) => void;
|
|
43
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>;
|
|
44
46
|
};
|