@fileverse-dev/ddoc 3.2.1-sg-1 → 3.2.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.
@@ -26,13 +26,7 @@ export interface CommentFloatingThreadCard extends CommentFloatingBaseCard {
26
26
  type: 'thread';
27
27
  commentId: string;
28
28
  }
29
- export interface SuggestionFloatingDraftCard extends CommentFloatingBaseCard {
30
- type: 'suggestion-draft';
31
- suggestionId: string;
32
- /** Accumulated inserted text from the live suggestion context. */
33
- insertedText: string;
34
- }
35
- export type CommentFloatingCard = CommentFloatingDraftCard | CommentFloatingThreadCard | SuggestionFloatingDraftCard;
29
+ export type CommentFloatingCard = CommentFloatingDraftCard | CommentFloatingThreadCard;
36
30
  export interface InlineCommentData {
37
31
  highlightedTextContent?: string;
38
32
  inlineCommentText: string;
@@ -1,7 +1,7 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import { ReactNode, RefObject } from 'react';
3
3
  import { IComment } from '../../../extensions/comment';
4
- import { CommentFloatingDraftCard, CommentFloatingThreadCard, SuggestionFloatingDraftCard } from '../context/types';
4
+ import { CommentFloatingDraftCard, CommentFloatingThreadCard } from '../context/types';
5
5
 
6
6
  export type RegisterCardNode = (floatingCardId: string, node: HTMLDivElement | null) => void;
7
7
  export interface CommentFloatingContainerProps {
@@ -32,8 +32,3 @@ export interface ThreadFloatingCardProps {
32
32
  registerCardNode: RegisterCardNode;
33
33
  isCollaborationEnabled?: boolean;
34
34
  }
35
- export interface SuggestionDraftFloatingCardProps {
36
- card: SuggestionFloatingDraftCard;
37
- isHidden: boolean;
38
- registerCardNode: RegisterCardNode;
39
- }
@@ -2,7 +2,7 @@ import { Editor } from '@tiptap/react';
2
2
  import { FloatingLayoutInvalidationFlag, FloatingCardLayoutInput } from './comment-floating-layout';
3
3
  import { CommentFloatingCard } from './context/types';
4
4
 
5
- export type AnchorType = 'draft' | 'thread' | 'suggestion-draft';
5
+ export type AnchorType = 'draft' | 'thread';
6
6
  export interface CachedAnchorRect {
7
7
  top: number;
8
8
  height: number;
@@ -40,9 +40,6 @@ export declare const FLOATING_VIEWPORT_BUFFER_MULTIPLIER = 1;
40
40
  export declare const getAnchorIdentity: (floatingCard: CommentFloatingCard) => {
41
41
  anchorId: string;
42
42
  anchorType: "draft";
43
- } | {
44
- anchorId: string;
45
- anchorType: "suggestion-draft";
46
43
  } | {
47
44
  anchorId: string;
48
45
  anchorType: "thread";
@@ -2,7 +2,6 @@ import { Extension, Editor } from '@tiptap/core';
2
2
  import { EditorState, PluginKey } from '@tiptap/pm/state';
3
3
  import { Transform } from '@tiptap/pm/transform';
4
4
  import { DecorationSet } from '@tiptap/pm/view';
5
- import { SuggestionType } from '../../types';
6
5
 
7
6
  import * as Y from 'yjs';
8
7
  export interface CommentAnchor {
@@ -11,10 +10,6 @@ export interface CommentAnchor {
11
10
  anchorTo: Y.RelativePosition;
12
11
  resolved: boolean;
13
12
  deleted: boolean;
14
- isSuggestion?: boolean;
15
- suggestionType?: SuggestionType;
16
- originalContent?: string;
17
- suggestedContent?: string;
18
13
  }
19
14
  interface CommentDecorationPluginState {
20
15
  decorations: DecorationSet;
@@ -39,13 +34,6 @@ export type CommentAnchorTransactionChange = {
39
34
  } & CommentAnchorRange & CommentAnchorRelativeRange);
40
35
  export declare const commentDecorationPluginKey: PluginKey<CommentDecorationPluginState>;
41
36
  export declare function resolveCommentAnchorRangeInState(anchor: Pick<CommentAnchor, 'anchorFrom' | 'anchorTo'>, state: EditorState): CommentAnchorRange | null;
42
- /**
43
- * Resolve anchorFrom to a single absolute position.
44
- * Used for 'add' suggestion anchors where anchorFrom === anchorTo (cursor,
45
- * no initial selection) — resolveCommentAnchorRangeInState rejects from >= to,
46
- * so we need a separate path that allows a point position.
47
- */
48
- export declare function resolveCommentAnchorPointInState(anchor: Pick<CommentAnchor, 'anchorFrom'>, state: EditorState): number | null;
49
37
  export declare function resolveCommentAnchorRangeForAnalysis(anchor: Pick<CommentAnchor, 'id' | 'anchorFrom' | 'anchorTo'>, state: EditorState): CommentAnchorRange | null;
50
38
  /**
51
39
  * Analyze transaction changes to classify each active anchor's mutation status.
@@ -75,21 +63,8 @@ export declare const CommentDecorationExtension: Extension<CommentDecorationOpti
75
63
  * These are consumed by the draft-creation flow and transaction-analysis layer.
76
64
  */
77
65
  export declare function createCommentAnchorFromEditor(editor: Editor, from: number, to: number): CommentAnchorRelativeRange | null;
78
- /**
79
- * Create a point anchor (anchorFrom === anchorTo) at a single doc position.
80
- * Used by the suggestion-mode draft flow when the viewer places a cursor
81
- * without selecting text — createCommentAnchorFromEditor rejects from >= to
82
- * since an empty range is invalid for regular comments.
83
- */
84
- export declare function createCommentAnchorPointFromEditor(editor: Editor, pos: number): CommentAnchorRelativeRange | null;
85
66
  export declare function createCommentAnchorFromSelection(editor: Editor): CommentAnchorRelativeRange | null;
86
67
  export declare function triggerDecorationRebuild(editor: Editor): void;
87
68
  export declare function getCommentAtPosition(editor: Editor, pos: number, getAnchors: () => CommentAnchor[]): CommentAnchor | null;
88
69
  export declare function getCommentAnchorRange(editor: Editor, commentId: string, getAnchors: () => CommentAnchor[]): CommentAnchorRange | null;
89
- /**
90
- * Apply the accepted suggestion's change to the document.
91
- * Called by the store's acceptSuggestion action before resolving on-chain.
92
- * Returns false if the anchor can't be resolved or the suggestion type is unknown.
93
- */
94
- export declare function applyAcceptedSuggestion(editor: Editor, anchor: CommentAnchor): boolean;
95
70
  export {};
@@ -2,7 +2,6 @@ import { Mark, Range } from '@tiptap/core';
2
2
  import { Mark as PMMark } from '@tiptap/pm/model';
3
3
  import { PluginKey, EditorState } from '@tiptap/pm/state';
4
4
  import { DecorationSet } from '@tiptap/pm/view';
5
- import { SuggestionType } from '../../types';
6
5
 
7
6
  declare module '@tiptap/core' {
8
7
  interface Commands<ReturnType> {
@@ -94,10 +93,6 @@ export interface IComment {
94
93
  deleted?: boolean;
95
94
  commentIndex?: number;
96
95
  version?: string;
97
- isSuggestion?: boolean;
98
- suggestionType?: SuggestionType;
99
- originalContent?: string;
100
- suggestedContent?: string;
101
96
  }
102
97
  export declare const CommentExtension: Mark<CommentOptions, CommentStorage>;
103
98
  export {};
@@ -4,7 +4,6 @@ type EditingContextType = {
4
4
  isPreviewMode: boolean;
5
5
  isPresentationMode?: boolean;
6
6
  isCollaboratorsDoc?: boolean;
7
- isSuggestionMode?: boolean;
8
7
  };
9
8
  export declare const useEditingContext: () => EditingContextType;
10
9
  type EditingProviderProps = {
@@ -13,7 +12,6 @@ type EditingProviderProps = {
13
12
  isPresentationMode?: boolean;
14
13
  isCollaboratorsDoc?: boolean;
15
14
  isPreviewEditor?: boolean;
16
- isSuggestionMode?: boolean;
17
15
  };
18
16
  export declare const EditingProvider: React.FC<EditingProviderProps>;
19
17
  export {};
@@ -12,7 +12,6 @@ interface UseTabEditorArgs {
12
12
  hasTabState?: boolean;
13
13
  versionId?: string;
14
14
  isPreviewMode?: boolean;
15
- viewerMode?: DdocProps['viewerMode'];
16
15
  initialContent: DdocProps['initialContent'];
17
16
  collaboration?: CollaborationProps;
18
17
  isReady?: boolean;
@@ -52,7 +51,7 @@ interface UseTabEditorArgs {
52
51
  editorRef?: MutableRefObject<Editor | null>;
53
52
  initialCommentAnchors?: SerializedCommentAnchor[];
54
53
  }
55
- export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionId, isPreviewMode, viewerMode, initialContent, collaboration, isReady, isSyncing, awareness, disableInlineComment, isFocusMode, onCommentInteraction, onError, ipfsImageUploadFn, metadataProxyUrl, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, setCharacterCount, setWordCount, setPageCount, setIsContentLoading, setIsCollabContentLoading, unFocused, zoomLevel, isPresentationMode, onInvalidContentError, ignoreCorruptedData, onCollaboratorChange, onConnect, hasCollabContentInitialised, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, theme, editorRef, initialCommentAnchors, }: UseTabEditorArgs) => {
54
+ export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionId, isPreviewMode, initialContent, collaboration, isReady, isSyncing, awareness, disableInlineComment, isFocusMode, onCommentInteraction, onError, ipfsImageUploadFn, metadataProxyUrl, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, setCharacterCount, setWordCount, setPageCount, setIsContentLoading, setIsCollabContentLoading, unFocused, zoomLevel, isPresentationMode, onInvalidContentError, ignoreCorruptedData, onCollaboratorChange, onConnect, hasCollabContentInitialised, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, theme, editorRef, initialCommentAnchors, }: UseTabEditorArgs) => {
56
55
  editor: Editor | null;
57
56
  ref: import('react').RefObject<HTMLDivElement>;
58
57
  slides: string[];
@@ -64,7 +63,5 @@ export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionI
64
63
  focusCommentWithActiveId: (id: string) => void;
65
64
  isContentLoading: boolean | undefined;
66
65
  commentAnchorsRef: MutableRefObject<CommentAnchor[]>;
67
- draftAnchorsRef: MutableRefObject<CommentAnchor[]>;
68
- storeApiRef: MutableRefObject<import('zustand').StoreApi<import('../stores/comment-store').CommentStoreState> | null>;
69
66
  };
70
67
  export {};
@@ -3,7 +3,6 @@ import { Editor } from '@tiptap/core';
3
3
  import { IComment } from '../extensions/comment';
4
4
  import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
5
5
  import { CommentMutationMeta, SerializedCommentAnchor } from '../types';
6
- import { createCommentStore } from './comment-store';
7
6
 
8
7
  import * as Y from 'yjs';
9
8
  export interface CommentStoreProviderProps {
@@ -28,13 +27,6 @@ export interface CommentStoreProviderProps {
28
27
  connectViaUsername?: (username: string) => Promise<void>;
29
28
  ensResolutionUrl: string;
30
29
  commentAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
31
- draftAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
32
- /**
33
- * Ref populated by the provider with the Zustand store instance.
34
- * SuggestionTrackingExtension reads this inside event handlers to route
35
- * keystrokes into draft actions without rebuilding the editor.
36
- */
37
- storeApiRef?: React.MutableRefObject<ReturnType<typeof createCommentStore> | null>;
38
30
  initialCommentAnchors?: SerializedCommentAnchor[];
39
31
  initialComments: IComment[];
40
32
  username: string | null;
@@ -45,7 +37,7 @@ export interface CommentStoreProviderProps {
45
37
  isDDocOwner?: boolean;
46
38
  setUsername?: React.Dispatch<React.SetStateAction<string>>;
47
39
  }
48
- export declare const CommentStoreProvider: ({ children, editor, ydoc, isFocusMode, setActiveCommentId, focusCommentWithActiveId, setInitialComments, onNewComment, onEditComment, onEditReply, onCommentReply, onResolveComment, onUnresolveComment, onDeleteComment, onInlineComment, onComment, setCommentDrawerOpen, connectViaWallet, connectViaUsername, ensResolutionUrl, commentAnchorsRef, draftAnchorsRef, storeApiRef, initialCommentAnchors, setUsername: setUsernameProp, initialComments, username, activeCommentId, activeTabId, isConnected, isLoading, isDDocOwner, }: CommentStoreProviderProps) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const CommentStoreProvider: ({ children, editor, ydoc, isFocusMode, setActiveCommentId, focusCommentWithActiveId, setInitialComments, onNewComment, onEditComment, onEditReply, onCommentReply, onResolveComment, onUnresolveComment, onDeleteComment, onInlineComment, onComment, setCommentDrawerOpen, connectViaWallet, connectViaUsername, ensResolutionUrl, commentAnchorsRef, initialCommentAnchors, setUsername: setUsernameProp, initialComments, username, activeCommentId, activeTabId, isConnected, isLoading, isDDocOwner, }: CommentStoreProviderProps) => import("react/jsx-runtime").JSX.Element;
49
41
  interface CommentRefsContextType {
50
42
  commentsSectionRef: React.RefObject<HTMLDivElement>;
51
43
  replySectionRef: React.RefObject<HTMLDivElement>;
@@ -29,33 +29,6 @@ export interface CommentExternalDeps {
29
29
  ensResolutionUrl: string;
30
30
  commentAnchorsRef?: React.MutableRefObject<CommentAnchor[]>;
31
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
32
  }
60
33
  type FloatingCardsUpdater = React.SetStateAction<CommentFloatingCard[]>;
61
34
  type InlineCommentDataUpdater = Partial<InlineCommentData> | ((prev: InlineCommentData) => Partial<InlineCommentData> | InlineCommentData);
@@ -119,14 +92,6 @@ export interface CommentStoreState {
119
92
  inlineCommentData: InlineCommentData;
120
93
  floatingCards: CommentFloatingCard[];
121
94
  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
95
  inlineDrafts: InlineDraftRecordMap;
131
96
  activeDraftId: string | null;
132
97
  isDesktopFloatingEnabled: boolean;
@@ -212,39 +177,6 @@ export interface CommentStoreState {
212
177
  deleteComment: (commentId: string, options?: {
213
178
  skipExternalCallback?: boolean;
214
179
  }) => 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
180
  deleteReply: (commentId: string, replyId: string) => void;
249
181
  requestEditComment: (commentId: string) => void;
250
182
  requestEditReply: (commentId: string, replyId: string) => void;
@@ -20,7 +20,6 @@ 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';
24
23
  export interface CommentMutationMeta {
25
24
  type: CommentMutationType;
26
25
  updateChunk?: string;
@@ -28,9 +27,6 @@ export interface CommentMutationMeta {
28
27
  anchorTo?: string;
29
28
  selectedContent?: string;
30
29
  content?: string;
31
- suggestionType?: SuggestionType;
32
- originalContent?: string;
33
- suggestedContent?: string;
34
30
  }
35
31
  export interface SerializedCommentAnchor {
36
32
  id: string;
@@ -38,10 +34,6 @@ export interface SerializedCommentAnchor {
38
34
  anchorTo: string;
39
35
  resolved: boolean;
40
36
  deleted: boolean;
41
- isSuggestion?: boolean;
42
- suggestionType?: SuggestionType;
43
- originalContent?: string;
44
- suggestedContent?: string;
45
37
  }
46
38
  export interface CommentAccountProps {
47
39
  isConnected?: boolean;
@@ -152,7 +144,6 @@ export interface DdocProps extends CommentAccountProps {
152
144
  editorCanvasClassNames?: string;
153
145
  isCommentSectionOpen?: boolean;
154
146
  isPreviewMode: boolean;
155
- viewerMode?: 'suggest' | 'view-only';
156
147
  ensResolutionUrl?: string;
157
148
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
158
149
  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, 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> & {
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> & {
5
5
  isFocusMode?: boolean;
6
6
  }) => {
7
7
  ydoc: import('yjs').Doc;
@@ -41,6 +41,4 @@ export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent
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>;
46
44
  };