@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.
Files changed (54) hide show
  1. package/dist/index.es.js +35271 -30419
  2. package/dist/package/components/editor-bubble-menu/props.d.ts +2 -0
  3. package/dist/package/components/inline-comment/comment-card.d.ts +1 -1
  4. package/dist/package/components/inline-comment/comment-drawer.d.ts +1 -1
  5. package/dist/package/components/inline-comment/comment-dropdown.d.ts +1 -1
  6. package/dist/package/components/inline-comment/comment-floating-container.d.ts +1 -0
  7. package/dist/package/components/inline-comment/comment-floating-layout.d.ts +34 -0
  8. package/dist/package/components/inline-comment/comment-input-field.d.ts +4 -0
  9. package/dist/package/components/inline-comment/comment-reply-input.d.ts +8 -0
  10. package/dist/package/components/inline-comment/comment-section.d.ts +1 -1
  11. package/dist/package/components/inline-comment/comment-username.d.ts +1 -1
  12. package/dist/package/components/inline-comment/constants.d.ts +1 -0
  13. package/dist/package/components/inline-comment/context/types.d.ts +52 -89
  14. package/dist/package/components/inline-comment/delete-confirm-overlay.d.ts +10 -0
  15. package/dist/package/components/inline-comment/empty-comments.d.ts +4 -1
  16. package/dist/package/components/inline-comment/floating-comment/comment-floating-container.d.ts +3 -0
  17. package/dist/package/components/inline-comment/floating-comment/draft-floating-card.d.ts +3 -0
  18. package/dist/package/components/inline-comment/floating-comment/floating-auth-prompt.d.ts +1 -0
  19. package/dist/package/components/inline-comment/floating-comment/floating-card-shell.d.ts +3 -0
  20. package/dist/package/components/inline-comment/floating-comment/index.d.ts +1 -0
  21. package/dist/package/components/inline-comment/floating-comment/suggestion-draft-floating-card.d.ts +11 -0
  22. package/dist/package/components/inline-comment/floating-comment/suggestion-thread-floating-card.d.ts +15 -0
  23. package/dist/package/components/inline-comment/floating-comment/thread-floating-card.d.ts +3 -0
  24. package/dist/package/components/inline-comment/floating-comment/types.d.ts +39 -0
  25. package/dist/package/components/inline-comment/floating-comment-layout-utils.d.ts +81 -0
  26. package/dist/package/components/inline-comment/resize-inline-comment-textarea.d.ts +1 -0
  27. package/dist/package/components/inline-comment/types.d.ts +24 -0
  28. package/dist/package/components/inline-comment/use-anchor-registry.d.ts +34 -0
  29. package/dist/package/components/inline-comment/use-comment-card.d.ts +29 -0
  30. package/dist/package/components/inline-comment/use-comment-list-container.d.ts +17 -0
  31. package/dist/package/components/inline-comment/use-ens-status.d.ts +3 -0
  32. package/dist/package/components/inline-comment/use-floating-card-state.d.ts +36 -0
  33. package/dist/package/components/inline-comment/use-floating-comment-card-layout.d.ts +23 -0
  34. package/dist/package/components/inline-comment/use-floating-comment-card-state.d.ts +13 -0
  35. package/dist/package/components/inline-comment/use-floating-layout-engine.d.ts +26 -0
  36. package/dist/package/components/inline-comment/use-is-selected-content-deleted.d.ts +1 -0
  37. package/dist/package/components/tabs/document-tabs-sidebar.d.ts +2 -1
  38. package/dist/package/extensions/comment/comment-decoration-plugin.d.ts +95 -0
  39. package/dist/package/extensions/comment/comment.d.ts +38 -0
  40. package/dist/package/extensions/resizable-media/resizable-media-menu-util.d.ts +5 -4
  41. package/dist/package/extensions/resizable-media/resizable-media-node-view.d.ts +1 -1
  42. package/dist/package/extensions/suggestion/suggestion-tracking-extension.d.ts +30 -0
  43. package/dist/package/hooks/use-editing-context.d.ts +2 -0
  44. package/dist/package/hooks/use-tab-editor.d.ts +9 -2
  45. package/dist/package/stores/comment-store-provider.d.ts +64 -0
  46. package/dist/package/stores/comment-store.d.ts +263 -0
  47. package/dist/package/types.d.ts +25 -2
  48. package/dist/package/use-ddoc-editor.d.ts +6 -1
  49. package/dist/package/utils/comment-anchor-serialization.d.ts +5 -0
  50. package/dist/package/utils/comment-scroll-into-view.d.ts +21 -0
  51. package/dist/style.css +1 -1
  52. package/package.json +4 -3
  53. package/dist/package/components/inline-comment/context/comment-context.d.ts +0 -4
  54. package/dist/package/extensions/resizable-media/media-caption.d.ts +0 -3
@@ -0,0 +1,36 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { FloatingLayoutInvalidationFlag, FloatingCardLayoutInput } from './comment-floating-layout';
3
+ import { CommentFloatingCard } from './context/types';
4
+ import { FloatingCardRuntimeState } from './floating-comment-layout-utils';
5
+
6
+ interface SyncMountedFloatingCardIdsResult {
7
+ didChange: boolean;
8
+ previousMountedFloatingCardIds: Set<string>;
9
+ }
10
+ export interface UseFloatingCardStateResult {
11
+ floatingCardStateRef: MutableRefObject<Map<string, FloatingCardRuntimeState>>;
12
+ orderedFloatingCardIdsRef: MutableRefObject<string[]>;
13
+ orderDirtyRef: MutableRefObject<boolean>;
14
+ heightMeasurementQueueRef: MutableRefObject<Set<string>>;
15
+ layoutBoundaryRef: MutableRefObject<{
16
+ recomputeFromIndex: number;
17
+ }>;
18
+ mountedFloatingCardIdsRef: MutableRefObject<string[]>;
19
+ mountedFloatingCardIds: string[];
20
+ getFloatingCardRuntimeState: (floatingCardId: string) => FloatingCardRuntimeState;
21
+ getOrderedFloatingCardIndex: (floatingCardId: string) => number | null;
22
+ markRecomputeFromIndex: (recomputeFromIndex: number) => void;
23
+ markFloatingCardInvalidated: (floatingCardId: string, flag: FloatingLayoutInvalidationFlag) => void;
24
+ markFloatingCardOrderDirty: () => void;
25
+ reconcileFloatingCardOrder: (nextFloatingCards: CommentFloatingCard[]) => {
26
+ orderedFloatingCardIds: string[];
27
+ firstChangedIndex: number | null;
28
+ };
29
+ pruneFloatingCardRuntimeState: (activeFloatingCardIds: Set<string>) => void;
30
+ syncMountedFloatingCardIds: (nextMountedFloatingCardIds: string[]) => SyncMountedFloatingCardIdsResult;
31
+ clearInvalidationFlagsThroughIndex: (stopIndex: number) => void;
32
+ getFloatingCardLayoutInputs: () => FloatingCardLayoutInput[];
33
+ resetFloatingCardState: () => void;
34
+ }
35
+ export declare const useFloatingCardState: () => UseFloatingCardStateResult;
36
+ export {};
@@ -0,0 +1,23 @@
1
+ import { RefObject } from 'react';
2
+ import { Editor } from '@tiptap/react';
3
+ import { CommentFloatingCard } from './context/types';
4
+
5
+ interface UseFloatingCommentCardLayoutProps {
6
+ blurFloatingCard: (floatingCardId: string) => void;
7
+ closeFloatingCard: (floatingCardId: string) => void;
8
+ editor: Editor;
9
+ editorWrapperRef: RefObject<HTMLDivElement>;
10
+ floatingCardIdsKey: string;
11
+ floatingCards: CommentFloatingCard[];
12
+ focusedFloatingCardId: string | null;
13
+ isDesktopFloatingEnabled: boolean;
14
+ isHidden: boolean;
15
+ scrollContainerRef: RefObject<HTMLDivElement>;
16
+ }
17
+ interface UseFloatingCommentCardLayoutResult {
18
+ floatingCardListContainerRef: RefObject<HTMLDivElement>;
19
+ mountedFloatingCardIds: string[];
20
+ registerCardNode: (floatingCardId: string, node: HTMLDivElement | null) => void;
21
+ }
22
+ export declare const useFloatingCommentCardLayout: ({ blurFloatingCard, closeFloatingCard, editor, editorWrapperRef, floatingCardIdsKey, floatingCards, focusedFloatingCardId, isDesktopFloatingEnabled, isHidden, scrollContainerRef, }: UseFloatingCommentCardLayoutProps) => UseFloatingCommentCardLayoutResult;
23
+ export {};
@@ -0,0 +1,13 @@
1
+ import { CommentFloatingCard } from './context/types';
2
+
3
+ interface UseFloatingCommentCardStateResult {
4
+ blurFloatingCard: (floatingCardId: string) => void;
5
+ closeFloatingCard: (floatingCardId: string) => void;
6
+ floatingCardIdsKey: string;
7
+ floatingCardMap: Map<string, CommentFloatingCard>;
8
+ floatingCards: CommentFloatingCard[];
9
+ focusedFloatingCardId: string | null;
10
+ isDesktopFloatingEnabled: boolean;
11
+ }
12
+ export declare const useFloatingCommentCardState: () => UseFloatingCommentCardStateResult;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ import { RefObject } from 'react';
2
+ import { Editor } from '@tiptap/react';
3
+ import { CommentFloatingCard } from './context/types';
4
+ import { UseAnchorRegistryResult } from './use-anchor-registry';
5
+ import { UseFloatingCardStateResult } from './use-floating-card-state';
6
+
7
+ interface UseFloatingLayoutEngineProps {
8
+ blurFloatingCard: (floatingCardId: string) => void;
9
+ closeFloatingCard: (floatingCardId: string) => void;
10
+ editor: Editor;
11
+ editorWrapperRef: RefObject<HTMLDivElement>;
12
+ floatingCardIdsKey: string;
13
+ floatingCards: CommentFloatingCard[];
14
+ focusedFloatingCardId: string | null;
15
+ isDesktopFloatingEnabled: boolean;
16
+ isHidden: boolean;
17
+ scrollContainerRef: RefObject<HTMLDivElement>;
18
+ anchorRegistry: UseAnchorRegistryResult;
19
+ floatingCardState: UseFloatingCardStateResult;
20
+ }
21
+ export interface UseFloatingLayoutEngineResult {
22
+ floatingCardListContainerRef: RefObject<HTMLDivElement>;
23
+ registerCardNode: (floatingCardId: string, node: HTMLDivElement | null) => void;
24
+ }
25
+ export declare const useFloatingLayoutEngine: ({ blurFloatingCard, closeFloatingCard, editor, editorWrapperRef, floatingCardIdsKey, floatingCards, focusedFloatingCardId, isDesktopFloatingEnabled, isHidden, scrollContainerRef, anchorRegistry, floatingCardState, }: UseFloatingLayoutEngineProps) => UseFloatingLayoutEngineResult;
26
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useIsSelectedContentDeleted(commentId: string | undefined, selectedContent: string | undefined, commentTabId: string | undefined): boolean;
@@ -31,9 +31,10 @@ export interface DocumentTabsSidebarProps {
31
31
  tabConfig?: DocumentOutlineProps['tabConfig'];
32
32
  deleteTab?: (tabId: string) => void;
33
33
  isConnected?: boolean;
34
+ isFocusMode?: boolean;
34
35
  }
35
36
  export declare const DocumentTabsSidebar: ({ tabSectionContainer, ...rest }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element | null;
36
- export declare const TabSidebar: ({ tabs, activeTabId, setActiveTabId, showTOC, setShowTOC, hasToC, isPreviewMode, editor, items, setItems, orientation, createTab, renameTab, duplicateTab, orderTab, tabCommentCounts, isVersionHistoryMode, tabConfig, deleteTab, isConnected, }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const TabSidebar: ({ tabs, activeTabId, setActiveTabId, showTOC, setShowTOC, hasToC, isPreviewMode, editor, items, setItems, orientation, createTab, renameTab, duplicateTab, orderTab, tabCommentCounts, isVersionHistoryMode, tabConfig, deleteTab, isConnected, isFocusMode, }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element;
37
38
  export declare const DdocTab: ({ tab, tabIndex, tabCount, handleEmojiChange, handleNameChange, onClick, editor, tocItem, setTocItems, orientation, activeTabId, duplicateTab, commentCount, moveTabUp, moveTabDown, isPreviewMode, isVersionHistoryMode, tabConfig, onDelete, showOutline, onShowOutlineChange, isConnected, }: {
38
39
  tab: Tab;
39
40
  tabIndex: number;
@@ -0,0 +1,95 @@
1
+ import { Extension, Editor } from '@tiptap/core';
2
+ import { EditorState, PluginKey } from '@tiptap/pm/state';
3
+ import { Transform } from '@tiptap/pm/transform';
4
+ import { DecorationSet } from '@tiptap/pm/view';
5
+ import { SuggestionType } from '../../types';
6
+
7
+ import * as Y from 'yjs';
8
+ export interface CommentAnchor {
9
+ id: string;
10
+ anchorFrom: Y.RelativePosition;
11
+ anchorTo: Y.RelativePosition;
12
+ resolved: boolean;
13
+ deleted: boolean;
14
+ isSuggestion?: boolean;
15
+ suggestionType?: SuggestionType;
16
+ originalContent?: string;
17
+ suggestedContent?: string;
18
+ }
19
+ interface CommentDecorationPluginState {
20
+ decorations: DecorationSet;
21
+ }
22
+ type CommentAnchorRange = {
23
+ from: number;
24
+ to: number;
25
+ };
26
+ type CommentAnchorRelativeRange = {
27
+ anchorFrom: Y.RelativePosition;
28
+ anchorTo: Y.RelativePosition;
29
+ };
30
+ export type CommentAnchorTransactionChange = {
31
+ id: string;
32
+ type: 'unchanged';
33
+ } | {
34
+ id: string;
35
+ type: 'deleted';
36
+ } | ({
37
+ id: string;
38
+ type: 'edited';
39
+ } & CommentAnchorRange & CommentAnchorRelativeRange);
40
+ export declare const commentDecorationPluginKey: PluginKey<CommentDecorationPluginState>;
41
+ 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
+ export declare function resolveCommentAnchorRangeForAnalysis(anchor: Pick<CommentAnchor, 'id' | 'anchorFrom' | 'anchorTo'>, state: EditorState): CommentAnchorRange | null;
50
+ /**
51
+ * Analyze transaction changes to classify each active anchor's mutation status.
52
+ *
53
+ * This is the core transaction analysis function that determines
54
+ * whether each anchor remains unchanged, gets edited, or is deleted.
55
+ *
56
+ * Classification rules (in order):
57
+ * 1. Skip deleted or resolved anchors → 'unchanged'
58
+ * 2. If anchor has no old position → 'unchanged'
59
+ * 3. If no changed ranges touch the anchor → 'unchanged'
60
+ * 4. If any changed range fully covers the anchor → 'deleted' (full-span replacement)
61
+ * 5. If combined changed ranges fully cover the anchor → 'deleted' (multi-step removal)
62
+ * 6. If anchor maps through transform → check if position or content changed:
63
+ * a. If both unchanged → 'unchanged'
64
+ * b. Otherwise → 'edited' (return new position and relative anchor)
65
+ * 7. If mapping fails → 'deleted'
66
+ */
67
+ export declare function analyzeCommentAnchorTransactionChanges(anchors: CommentAnchor[], oldState: EditorState, newState: EditorState, transform: Transform): CommentAnchorTransactionChange[];
68
+ export interface CommentDecorationOptions {
69
+ getAnchors: () => CommentAnchor[];
70
+ getActiveCommentId: () => string | null;
71
+ }
72
+ export declare const CommentDecorationExtension: Extension<CommentDecorationOptions, any>;
73
+ /**
74
+ * Public helper functions for comment anchor creation and inspection.
75
+ * These are consumed by the draft-creation flow and transaction-analysis layer.
76
+ */
77
+ 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
+ export declare function createCommentAnchorFromSelection(editor: Editor): CommentAnchorRelativeRange | null;
86
+ export declare function triggerDecorationRebuild(editor: Editor): void;
87
+ export declare function getCommentAtPosition(editor: Editor, pos: number, getAnchors: () => CommentAnchor[]): CommentAnchor | null;
88
+ 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
+ export {};
@@ -1,5 +1,8 @@
1
1
  import { Mark, Range } from '@tiptap/core';
2
2
  import { Mark as PMMark } from '@tiptap/pm/model';
3
+ import { PluginKey, EditorState } from '@tiptap/pm/state';
4
+ import { DecorationSet } from '@tiptap/pm/view';
5
+ import { SuggestionType } from '../../types';
3
6
 
4
7
  declare module '@tiptap/core' {
5
8
  interface Commands<ReturnType> {
@@ -28,6 +31,18 @@ declare module '@tiptap/core' {
28
31
  * Unset comment active
29
32
  */
30
33
  unsetCommentActive: () => ReturnType;
34
+ /**
35
+ * Add a local draft anchor that tracks through transactions.
36
+ */
37
+ setDraftComment: (draftId: string) => ReturnType;
38
+ /**
39
+ * Remove a local draft anchor.
40
+ */
41
+ unsetDraftComment: (draftId: string) => ReturnType;
42
+ /**
43
+ * Replace a draft anchor with a persisted comment mark.
44
+ */
45
+ promoteDraftComment: (draftId: string, commentId: string) => ReturnType;
31
46
  };
32
47
  }
33
48
  }
@@ -35,6 +50,10 @@ export interface MarkWithRange {
35
50
  mark: PMMark;
36
51
  range: Range;
37
52
  }
53
+ export interface CommentMarkMatch {
54
+ commentId: string;
55
+ resolved: boolean;
56
+ }
38
57
  export interface CommentOptions {
39
58
  HTMLAttributes: Record<string, any>;
40
59
  onCommentActivated: (commentId: string) => void;
@@ -45,6 +64,20 @@ export interface CommentOptions {
45
64
  export interface CommentStorage {
46
65
  activeCommentId: string | null;
47
66
  }
67
+ export interface DraftCommentRange {
68
+ draftId: string;
69
+ from: number;
70
+ to: number;
71
+ }
72
+ interface DraftCommentPluginState {
73
+ decorations: DecorationSet;
74
+ drafts: Map<string, DraftCommentRange>;
75
+ }
76
+ export declare const draftCommentPluginKey: PluginKey<DraftCommentPluginState>;
77
+ export declare const getDraftCommentState: (state: EditorState) => DraftCommentPluginState | undefined;
78
+ export declare const getDraftCommentRange: (state: EditorState, draftId: string) => DraftCommentRange | null;
79
+ export declare const getCommentMarkAtPosition: (state: EditorState, pos: number) => CommentMarkMatch | null;
80
+ export declare const getCommentMarkRange: (state: EditorState, commentId: string) => Range | null;
48
81
  export interface IComment {
49
82
  id?: string;
50
83
  tabId?: string;
@@ -61,5 +94,10 @@ export interface IComment {
61
94
  deleted?: boolean;
62
95
  commentIndex?: number;
63
96
  version?: string;
97
+ isSuggestion?: boolean;
98
+ suggestionType?: SuggestionType;
99
+ originalContent?: string;
100
+ suggestedContent?: string;
64
101
  }
65
102
  export declare const CommentExtension: Mark<CommentOptions, CommentStorage>;
103
+ export {};
@@ -1,17 +1,18 @@
1
- import { Attrs, Node as ProseMirrorNode } from '@tiptap/pm/model';
2
- import { Editor } from '@tiptap/core';
1
+ import { Attrs } from '@tiptap/pm/model';
3
2
 
4
3
  interface ResizableMediaAttributes {
5
4
  dataAlign: string;
6
5
  dataFloat: null | string;
6
+ showCaptionInput?: boolean;
7
+ caption?: string;
7
8
  }
8
9
  type UpdateAttributes = (attrs: Partial<ResizableMediaAttributes>) => void;
9
- type Action = (updateAttributes: UpdateAttributes, editor?: Editor, getPos?: (() => number | undefined) | boolean) => void;
10
+ type Action = (updateAttributes: UpdateAttributes) => void;
10
11
  interface ResizableMediaAction {
11
12
  tooltip: string;
12
13
  icon?: string;
13
14
  action?: Action;
14
- isActive?: (attrs: Attrs, node?: ProseMirrorNode) => boolean;
15
+ isActive?: (attrs: Attrs) => boolean;
15
16
  delete?: (d: () => void) => void;
16
17
  }
17
18
  export declare const resizableMediaActions: ResizableMediaAction[];
@@ -4,4 +4,4 @@ import { IpfsImageFetchPayload } from '../../types.ts';
4
4
  export declare const getResizableMediaNodeView: (ipfsImageFetchFn: (_data: IpfsImageFetchPayload) => Promise<{
5
5
  url: string;
6
6
  file: File;
7
- }>, fetchV1ImageFn: (url: string) => Promise<ArrayBuffer | undefined>) => ({ node, updateAttributes, deleteNode, selected, editor, getPos, }: NodeViewProps) => import("react/jsx-runtime").JSX.Element;
7
+ }>, fetchV1ImageFn: (url: string) => Promise<ArrayBuffer | undefined>) => ({ node, updateAttributes, deleteNode, selected }: NodeViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { PluginKey } from '@tiptap/pm/state';
3
+ import { SuggestionType } from '../../types';
4
+ import { CommentAnchor } from '../comment/comment-decoration-plugin';
5
+
6
+ import * as Y from 'yjs';
7
+ export interface SuggestionReadyData {
8
+ suggestionId: string;
9
+ anchorFrom: Y.RelativePosition;
10
+ anchorTo: Y.RelativePosition;
11
+ suggestionType: SuggestionType;
12
+ originalContent: string;
13
+ suggestedContent: string;
14
+ }
15
+ export interface SuggestionTrackingOptions {
16
+ /** Returns true when the editor is in suggestion mode. */
17
+ getIsSuggestionMode: () => boolean;
18
+ /** Viewer types text with a collapsed cursor (Add gesture). */
19
+ onTextInput: (text: string) => void;
20
+ /** Viewer types text over a non-empty selection (Replace gesture). */
21
+ onReplaceTyping: (from: number, to: number, text: string) => void;
22
+ /** Viewer presses Backspace/Delete with a non-empty selection. */
23
+ onDeleteSelection: (from: number, to: number) => void;
24
+ /** Viewer presses Cmd+Z (or Ctrl+Z). Shrinks the active draft by one keystroke. */
25
+ onUndo: () => void;
26
+ onLiveSuggestion?: ((anchor: CommentAnchor) => void) | null;
27
+ onSuggestionReady?: ((data: SuggestionReadyData) => void) | null;
28
+ }
29
+ export declare const suggestionTrackingPluginKey: PluginKey<null>;
30
+ export declare const SuggestionTrackingExtension: Extension<SuggestionTrackingOptions, any>;
@@ -4,6 +4,7 @@ type EditingContextType = {
4
4
  isPreviewMode: boolean;
5
5
  isPresentationMode?: boolean;
6
6
  isCollaboratorsDoc?: boolean;
7
+ isSuggestionMode?: boolean;
7
8
  };
8
9
  export declare const useEditingContext: () => EditingContextType;
9
10
  type EditingProviderProps = {
@@ -12,6 +13,7 @@ type EditingProviderProps = {
12
13
  isPresentationMode?: boolean;
13
14
  isCollaboratorsDoc?: boolean;
14
15
  isPreviewEditor?: boolean;
16
+ isSuggestionMode?: boolean;
15
17
  };
16
18
  export declare const EditingProvider: React.FC<EditingProviderProps>;
17
19
  export {};
@@ -1,6 +1,7 @@
1
1
  import { Dispatch, MutableRefObject, SetStateAction } from 'react';
2
- import { DdocProps, ThemeKey } from '../types';
2
+ import { DdocProps, SerializedCommentAnchor, ThemeKey } from '../types';
3
3
  import { AnyExtension, Editor } from '@tiptap/react';
4
+ import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
4
5
  import { ToCItemType } from '../components/toc/types';
5
6
  import { CollabConnectionConfig, CollaborationProps } from '../sync-local/types';
6
7
 
@@ -11,12 +12,14 @@ interface UseTabEditorArgs {
11
12
  hasTabState?: boolean;
12
13
  versionId?: string;
13
14
  isPreviewMode?: boolean;
15
+ viewerMode?: DdocProps['viewerMode'];
14
16
  initialContent: DdocProps['initialContent'];
15
17
  collaboration?: CollaborationProps;
16
18
  isReady?: boolean;
17
19
  isSyncing?: boolean;
18
20
  awareness?: any;
19
21
  disableInlineComment?: boolean;
22
+ isFocusMode?: boolean;
20
23
  onCommentInteraction?: DdocProps['onCommentInteraction'];
21
24
  onError?: DdocProps['onError'];
22
25
  ipfsImageUploadFn?: DdocProps['ipfsImageUploadFn'];
@@ -47,8 +50,9 @@ interface UseTabEditorArgs {
47
50
  activeTabId: string;
48
51
  theme?: ThemeKey;
49
52
  editorRef?: MutableRefObject<Editor | null>;
53
+ initialCommentAnchors?: SerializedCommentAnchor[];
50
54
  }
51
- export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionId, isPreviewMode, initialContent, collaboration, isReady, isSyncing, awareness, disableInlineComment, 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, }: UseTabEditorArgs) => {
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) => {
52
56
  editor: Editor | null;
53
57
  ref: import('react').RefObject<HTMLDivElement>;
54
58
  slides: string[];
@@ -59,5 +63,8 @@ export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionI
59
63
  setActiveCommentId: Dispatch<SetStateAction<string | null>>;
60
64
  focusCommentWithActiveId: (id: string) => void;
61
65
  isContentLoading: boolean | undefined;
66
+ commentAnchorsRef: MutableRefObject<CommentAnchor[]>;
67
+ draftAnchorsRef: MutableRefObject<CommentAnchor[]>;
68
+ storeApiRef: MutableRefObject<import('zustand').StoreApi<import('../stores/comment-store').CommentStoreState> | null>;
62
69
  };
63
70
  export {};
@@ -0,0 +1,64 @@
1
+ import { default as React } from 'react';
2
+ import { Editor } from '@tiptap/core';
3
+ import { IComment } from '../extensions/comment';
4
+ import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
5
+ import { CommentMutationMeta, SerializedCommentAnchor } from '../types';
6
+ import { createCommentStore } from './comment-store';
7
+
8
+ import * as Y from 'yjs';
9
+ export interface CommentStoreProviderProps {
10
+ children: React.ReactNode;
11
+ editor: Editor | null;
12
+ ydoc: Y.Doc;
13
+ isFocusMode?: boolean;
14
+ setActiveCommentId: (id: string | null) => void;
15
+ focusCommentWithActiveId: (id: string) => void;
16
+ setInitialComments?: React.Dispatch<React.SetStateAction<IComment[]>>;
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
+ 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
+ initialCommentAnchors?: SerializedCommentAnchor[];
39
+ initialComments: IComment[];
40
+ username: string | null;
41
+ activeCommentId: string | null;
42
+ activeTabId: string;
43
+ isConnected?: boolean;
44
+ isLoading?: boolean;
45
+ isDDocOwner?: boolean;
46
+ setUsername?: React.Dispatch<React.SetStateAction<string>>;
47
+ }
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;
49
+ interface CommentRefsContextType {
50
+ commentsSectionRef: React.RefObject<HTMLDivElement>;
51
+ replySectionRef: React.RefObject<HTMLDivElement>;
52
+ portalRef: React.RefObject<HTMLDivElement>;
53
+ buttonRef: React.RefObject<HTMLDivElement>;
54
+ dropdownRef: React.RefObject<HTMLDivElement>;
55
+ mobileDraftRef: React.RefObject<HTMLDivElement>;
56
+ }
57
+ export declare const useCommentRefs: () => CommentRefsContextType;
58
+ interface CommentAnchorsContextType {
59
+ activeCommentAnchorIds: Set<string>;
60
+ activeCommentAnchorIdsTabId: string | null;
61
+ hasRenderedCommentAnchor: (commentId: string) => boolean;
62
+ }
63
+ export declare const useCommentAnchors: () => CommentAnchorsContextType;
64
+ export {};