@fileverse-dev/ddoc 2.1.2-patch-3.3 → 2.1.3-patch-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 (26) hide show
  1. package/dist/index.es.js +70782 -68482
  2. package/dist/package/components/editor-bubble-menu/editor-bubble-menu.d.ts +3 -0
  3. package/dist/package/components/editor-bubble-menu/node-selector.d.ts +3 -0
  4. package/dist/package/components/editor-bubble-menu/props.d.ts +58 -0
  5. package/dist/package/components/{editor-bubble-menu.d.ts → editor-bubble-menu/types.d.ts} +11 -5
  6. package/dist/package/components/inline-comment/comment-bubble-card.d.ts +7 -0
  7. package/dist/package/components/inline-comment/comment-card.d.ts +3 -0
  8. package/dist/package/components/inline-comment/comment-drawer.d.ts +3 -0
  9. package/dist/package/components/inline-comment/comment-dropdown.d.ts +3 -0
  10. package/dist/package/components/inline-comment/comment-section.d.ts +3 -0
  11. package/dist/package/components/inline-comment/comment-username.d.ts +4 -0
  12. package/dist/package/components/inline-comment/context/comment-context.d.ts +6 -0
  13. package/dist/package/components/inline-comment/context/types.d.ts +74 -0
  14. package/dist/package/components/inline-comment/empty-comments.d.ts +2 -0
  15. package/dist/package/components/inline-comment/types.d.ts +68 -0
  16. package/dist/package/components/inline-comment/use-comment-actions.d.ts +0 -0
  17. package/dist/package/components/presentation-mode/presentation-mode.d.ts +3 -3
  18. package/dist/package/extensions/comment/comment.d.ts +64 -0
  19. package/dist/package/extensions/comment/index.d.ts +2 -0
  20. package/dist/package/types.d.ts +23 -5
  21. package/dist/package/use-ddoc-editor.d.ts +3 -0
  22. package/dist/package/utils/helpers.d.ts +2 -0
  23. package/dist/package/utils/responsive.d.ts +7 -0
  24. package/dist/style.css +1 -1
  25. package/package.json +2 -1
  26. package/dist/package/components/node-selector.d.ts +0 -9
@@ -0,0 +1,3 @@
1
+ import { EditorBubbleMenuProps } from './types';
2
+
3
+ export declare const EditorBubbleMenu: (props: EditorBubbleMenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { NodeSelectorProps } from './types';
2
+
3
+ export declare const NodeSelector: ({ editor, elementRef }: NodeSelectorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { EditorBubbleMenuProps } from './types';
3
+
4
+ export declare const bubbleMenuProps: (props: EditorBubbleMenuProps) => {
5
+ tippyOptions: {
6
+ moveTransition: string;
7
+ duration: number;
8
+ animation: string;
9
+ zIndex: number;
10
+ appendTo: () => HTMLElement | null;
11
+ popperOptions: {
12
+ strategy: string;
13
+ modifiers: ({
14
+ name: string;
15
+ options: {
16
+ fallbackPlacements: string[];
17
+ altAxis?: undefined;
18
+ tether?: undefined;
19
+ };
20
+ } | {
21
+ name: string;
22
+ options: {
23
+ altAxis: boolean;
24
+ tether: boolean;
25
+ fallbackPlacements?: undefined;
26
+ };
27
+ })[];
28
+ };
29
+ };
30
+ className?: string | undefined;
31
+ editor: import('@tiptap/extension-bubble-menu').BubbleMenuPluginProps["editor"] | null;
32
+ pluginKey?: string | import('prosemirror-state').PluginKey<any> | undefined;
33
+ updateDelay?: number | undefined;
34
+ shouldShow?: ((props: {
35
+ editor: Editor;
36
+ element: HTMLElement;
37
+ view: import('prosemirror-view').EditorView;
38
+ state: import('prosemirror-state').EditorState;
39
+ oldState?: import('prosemirror-state').EditorState;
40
+ from: number;
41
+ to: number;
42
+ }) => boolean) | null | undefined;
43
+ activeCommentId: string | null;
44
+ isPreviewMode: boolean;
45
+ onError?: (errorString: string) => void;
46
+ zoomLevel: string;
47
+ setIsCommentSectionOpen?: (isOpen: boolean) => void;
48
+ inlineCommentData?: import('../../types').InlineCommentData;
49
+ setInlineCommentData?: React.Dispatch<React.SetStateAction<import('../../types').InlineCommentData>>;
50
+ walletAddress?: string;
51
+ username?: string;
52
+ onInlineComment?: () => void;
53
+ commentDrawerOpen?: boolean;
54
+ setCommentDrawerOpen?: React.Dispatch<import('react').SetStateAction<boolean>>;
55
+ };
56
+ export declare const shouldShow: ({ editor }: {
57
+ editor: Editor;
58
+ }) => boolean;
@@ -1,5 +1,6 @@
1
- import { BubbleMenuProps } from '@tiptap/react';
2
- import { default as React } from 'react';
1
+ import { BubbleMenuProps, Editor } from '@tiptap/react';
2
+ import { SetStateAction } from 'react';
3
+ import { InlineCommentData } from '../../types';
3
4
 
4
5
  export interface BubbleMenuItem {
5
6
  name: string;
@@ -7,7 +8,8 @@ export interface BubbleMenuItem {
7
8
  command: () => void;
8
9
  icon: any;
9
10
  }
10
- type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
11
+ export type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
12
+ activeCommentId: string | null;
11
13
  isPreviewMode: boolean;
12
14
  onError?: (errorString: string) => void;
13
15
  zoomLevel: string;
@@ -17,6 +19,10 @@ type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
17
19
  walletAddress?: string;
18
20
  username?: string;
19
21
  onInlineComment?: () => void;
22
+ commentDrawerOpen?: boolean;
23
+ setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
20
24
  };
21
- export declare const EditorBubbleMenu: (props: EditorBubbleMenuProps) => import("react/jsx-runtime").JSX.Element;
22
- export {};
25
+ export interface NodeSelectorProps {
26
+ editor: Editor;
27
+ elementRef: React.RefObject<HTMLDivElement>;
28
+ }
@@ -0,0 +1,7 @@
1
+ import { Editor } from '@tiptap/core';
2
+
3
+ export declare const CommentBubbleCard: ({ editor, activeCommentId, commentDrawerOpen, }: {
4
+ editor: Editor;
5
+ activeCommentId: string | null;
6
+ commentDrawerOpen: boolean;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { CommentCardProps } from './types';
2
+
3
+ export declare const CommentCard: ({ username, selectedContent, comment, createdAt, replies, onResolve, onDelete, onUnresolve, isResolved, isDropdown, activeCommentId, id, isDisabled, isCommentOwner, version, }: CommentCardProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { CommentDrawerProps } from './types';
2
+
3
+ export declare const CommentDrawer: ({ isOpen, onClose, isNavbarVisible, isPresentationMode, activeCommentId, isPreviewMode, }: CommentDrawerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { CommentDropdownProps } from './types';
2
+
3
+ export declare const CommentDropdown: ({ activeCommentId, initialComment, isBubbleMenu, selectedContent, isDisabled, isCommentOwner, }: CommentDropdownProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ import { CommentSectionProps } from './types';
2
+
3
+ export declare const CommentSection: ({ activeCommentId, isNavbarVisible, isPresentationMode, isOpen, }: CommentSectionProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { CommentUsernameProps } from './context/types';
2
+
3
+ declare const CommentUsername: ({ username, setUsername, isNavbarVisible, isConnected, connectViaUsername, connectViaWallet, isLoading, }: CommentUsernameProps) => import("react/jsx-runtime").JSX.Element;
4
+ export { CommentUsername };
@@ -0,0 +1,6 @@
1
+ import { CommentContextType, CommentProviderProps } from './types';
2
+ import { EnsStatus } from '../types';
3
+
4
+ export declare const CommentProvider: ({ children, editor, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const useComments: () => CommentContextType;
6
+ export declare const useEnsName: (username?: string) => EnsStatus;
@@ -0,0 +1,74 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { IComment } from '../../../extensions/comment';
3
+ import { SetStateAction } from 'react';
4
+ import { CommentAccountProps } from '../../../types';
5
+
6
+ export interface CommentContextType extends CommentAccountProps {
7
+ comments: IComment[];
8
+ setComments: React.Dispatch<SetStateAction<IComment[]>>;
9
+ editor: Editor;
10
+ username?: string | null;
11
+ setUsername?: React.Dispatch<SetStateAction<string>>;
12
+ showResolved: boolean;
13
+ setShowResolved: (show: boolean) => void;
14
+ resolveComment: (commentId: string) => void;
15
+ unresolveComment: (commentId: string) => void;
16
+ deleteComment: (commentId: string) => void;
17
+ handleAddReply: (activeCommentId: string, replyContent: string, onCommentReply: (activeCommentId: string, reply: IComment) => void) => void;
18
+ focusCommentInEditor: (commentId: string) => void;
19
+ handleReplyChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
20
+ handleCommentChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
21
+ handleCommentKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
22
+ handleReplySubmit: () => void;
23
+ toggleResolved: () => void;
24
+ openReplyId: string | null;
25
+ setOpenReplyId: (id: string | null) => void;
26
+ handleReplyKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
27
+ commentsSectionRef: React.RefObject<HTMLDivElement>;
28
+ replySectionRef: React.RefObject<HTMLDivElement>;
29
+ addComment: (content?: string) => void;
30
+ handleCommentSubmit: () => void;
31
+ reply: string;
32
+ setReply: React.Dispatch<React.SetStateAction<string>>;
33
+ comment: string;
34
+ setComment: React.Dispatch<React.SetStateAction<string>>;
35
+ onPrevComment: () => void;
36
+ onNextComment: () => void;
37
+ activeCommentIndex: number;
38
+ activeComment: IComment | undefined;
39
+ selectedText: string;
40
+ isCommentOpen: boolean;
41
+ onInlineCommentClick: (event: React.MouseEvent) => void;
42
+ handleInlineComment: () => void;
43
+ portalRef: React.RefObject<HTMLDivElement>;
44
+ buttonRef: React.RefObject<HTMLDivElement>;
45
+ dropdownRef: React.RefObject<HTMLDivElement>;
46
+ activeComments: IComment[];
47
+ handleInput: (e: React.FormEvent<HTMLTextAreaElement>, content: string) => void;
48
+ isCommentActive: boolean;
49
+ isCommentResolved: boolean;
50
+ ensResolutionUrl: string;
51
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
52
+ }
53
+ export interface CommentProviderProps extends CommentAccountProps {
54
+ children: React.ReactNode;
55
+ editor: Editor;
56
+ initialComments?: IComment[];
57
+ setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
58
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
59
+ onNewComment?: (newComment: IComment) => void;
60
+ onResolveComment?: (activeCommentId: string) => void;
61
+ onUnresolveComment?: (activeCommentId: string) => void;
62
+ onDeleteComment?: (activeCommentId: string) => void;
63
+ username: string | null;
64
+ setUsername?: React.Dispatch<SetStateAction<string>>;
65
+ activeCommentId: string | null;
66
+ setActiveCommentId: React.Dispatch<React.SetStateAction<string | null>>;
67
+ focusCommentWithActiveId: (id: string) => void;
68
+ ensResolutionUrl: string;
69
+ }
70
+ export interface CommentUsernameProps extends CommentAccountProps {
71
+ username?: string | null;
72
+ setUsername?: React.Dispatch<SetStateAction<string>>;
73
+ isNavbarVisible?: boolean;
74
+ }
@@ -0,0 +1,2 @@
1
+ declare const EmptyComments: () => import("react/jsx-runtime").JSX.Element;
2
+ export { EmptyComments };
@@ -0,0 +1,68 @@
1
+ import { BubbleMenuProps, Editor } from '@tiptap/react';
2
+ import { IComment } from '../../extensions/comment';
3
+ import { SetStateAction } from 'react';
4
+
5
+ export interface UseCommentActionsProps {
6
+ editor: Editor;
7
+ comments: IComment[];
8
+ setComments: (comments: IComment[]) => void;
9
+ }
10
+ export interface CommentDropdownProps {
11
+ editor: Editor;
12
+ onSubmit: (content: string) => string;
13
+ onClose: () => void;
14
+ setComments?: (comments: IComment[]) => void;
15
+ comments?: IComment[];
16
+ username?: string;
17
+ walletAddress?: string;
18
+ activeCommentId?: string;
19
+ commentDrawerOpen?: boolean;
20
+ setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
21
+ initialComment?: string;
22
+ isBubbleMenu?: boolean;
23
+ selectedContent?: string;
24
+ isDisabled?: boolean;
25
+ isCommentOwner?: boolean;
26
+ }
27
+ export interface CommentDrawerProps {
28
+ isOpen: boolean;
29
+ onClose: () => void;
30
+ isNavbarVisible: boolean;
31
+ isPresentationMode: boolean;
32
+ activeCommentId: string | null;
33
+ isPreviewMode: boolean;
34
+ }
35
+ export interface CommentCardProps extends IComment {
36
+ comment?: string;
37
+ onResolve?: (commentId: string) => void;
38
+ onDelete?: (commentId: string) => void;
39
+ onUnresolve?: (commentId: string) => void;
40
+ isResolved?: boolean;
41
+ isDropdown?: boolean;
42
+ activeCommentId?: string;
43
+ isDisabled?: boolean;
44
+ isCommentOwner?: boolean;
45
+ version?: string;
46
+ }
47
+ export type CommentBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
48
+ zoomLevel: string;
49
+ };
50
+ export interface CommentReplyProps {
51
+ reply: string;
52
+ username: string;
53
+ createdAt: Date;
54
+ }
55
+ export interface EnsStatus {
56
+ name: string;
57
+ isEns: boolean;
58
+ }
59
+ export interface CommentSectionProps {
60
+ activeCommentId: string | null;
61
+ isNavbarVisible?: boolean;
62
+ isPresentationMode?: boolean;
63
+ isOpen?: boolean;
64
+ }
65
+ export interface UserDisplayProps {
66
+ ensStatus: EnsStatus;
67
+ createdAt: Date | undefined;
68
+ }
@@ -4,9 +4,9 @@ interface PresentationModeProps {
4
4
  editor: Editor;
5
5
  onClose: () => void;
6
6
  isFullscreen: boolean;
7
- setIsFullscreen: (isFullscreen: boolean) => void;
7
+ setIsFullscreen: React.Dispatch<React.SetStateAction<boolean>>;
8
8
  onError?: (error: string) => void;
9
- setIsCommentSectionOpen: React.Dispatch<React.SetStateAction<boolean>> | undefined;
9
+ setCommentDrawerOpen: React.Dispatch<React.SetStateAction<boolean>> | undefined;
10
10
  sharedSlidesLink?: string;
11
11
  isPreviewMode: boolean;
12
12
  documentName: string;
@@ -14,5 +14,5 @@ interface PresentationModeProps {
14
14
  slides: string[];
15
15
  setSlides: React.Dispatch<React.SetStateAction<string[]>>;
16
16
  }
17
- export declare const PresentationMode: ({ editor, onClose, isFullscreen, setIsFullscreen, onError, setIsCommentSectionOpen, sharedSlidesLink, isPreviewMode, documentName, onSlidesShare, slides, setSlides, }: PresentationModeProps) => import("react/jsx-runtime").JSX.Element | null;
17
+ export declare const PresentationMode: ({ editor, onClose, isFullscreen, setIsFullscreen, onError, setCommentDrawerOpen, sharedSlidesLink, isPreviewMode, documentName, onSlidesShare, slides, setSlides, }: PresentationModeProps) => import("react/jsx-runtime").JSX.Element | null;
18
18
  export {};
@@ -0,0 +1,64 @@
1
+ import { Mark, Range } from '@tiptap/core';
2
+ import { Mark as PMMark } from '@tiptap/pm/model';
3
+
4
+ declare module '@tiptap/core' {
5
+ interface Commands<ReturnType> {
6
+ comment: {
7
+ /**
8
+ * Set a comment (add)
9
+ */
10
+ setComment: (commentId: string) => ReturnType;
11
+ /**
12
+ * Unset a comment (remove completely)
13
+ */
14
+ unsetComment: (commentId: string) => ReturnType;
15
+ /**
16
+ * Resolve a comment (keep ID but update styling)
17
+ */
18
+ resolveComment: (commentId: string) => ReturnType;
19
+ /**
20
+ * Unresolve a comment (switch back to unresolved state)
21
+ */
22
+ unresolveComment: (commentId: string) => ReturnType;
23
+ /**
24
+ * Set a comment active
25
+ */
26
+ setCommentActive: (commentId: string) => ReturnType;
27
+ /**
28
+ * Unset comment active
29
+ */
30
+ unsetCommentActive: () => ReturnType;
31
+ };
32
+ }
33
+ }
34
+ export interface MarkWithRange {
35
+ mark: PMMark;
36
+ range: Range;
37
+ }
38
+ export interface CommentOptions {
39
+ HTMLAttributes: Record<string, any>;
40
+ onCommentActivated: (commentId: string) => void;
41
+ onCommentResolved?: (commentId: string) => void;
42
+ onCommentUnresolved?: (commentId: string) => void;
43
+ onCommentDeleted?: (commentId: string) => void;
44
+ }
45
+ export interface CommentStorage {
46
+ activeCommentId: string | null;
47
+ }
48
+ export interface IComment {
49
+ id?: string;
50
+ username?: string;
51
+ reactions?: {
52
+ count: number;
53
+ type: string;
54
+ }[];
55
+ selectedContent?: string;
56
+ content?: string;
57
+ replies?: IComment[];
58
+ createdAt?: Date;
59
+ resolved?: boolean;
60
+ deleted?: boolean;
61
+ commentIndex?: number;
62
+ version?: string;
63
+ }
64
+ export declare const CommentExtension: Mark<CommentOptions, CommentStorage>;
@@ -0,0 +1,2 @@
1
+ export * from './comment';
2
+ export { CommentExtension as default } from './comment';
@@ -3,6 +3,7 @@ import { Extension, JSONContent } from '@tiptap/core';
3
3
  import { EditorProps } from '@tiptap/pm/view';
4
4
  import { Editor } from '@tiptap/react';
5
5
  import { default as React, SetStateAction } from 'react';
6
+ import { IComment } from './extensions/comment';
6
7
 
7
8
  export declare const DdocEditorProps: EditorProps;
8
9
  export interface IDocCollabUsers {
@@ -10,12 +11,28 @@ export interface IDocCollabUsers {
10
11
  isEns: string;
11
12
  color: string;
12
13
  }
13
- type InlineCommentData = {
14
+ export type InlineCommentData = {
14
15
  inlineCommentText: string;
15
16
  highlightedTextContent: string;
16
17
  handleClick: boolean;
17
18
  };
18
- export interface DdocProps {
19
+ export interface CommentAccountProps {
20
+ isConnected?: boolean;
21
+ connectViaWallet?: () => Promise<void>;
22
+ isLoading?: boolean;
23
+ connectViaUsername?: (username: string) => Promise<void>;
24
+ isDDocOwner?: boolean;
25
+ }
26
+ export interface DdocProps extends CommentAccountProps {
27
+ commentDrawerOpen?: boolean;
28
+ setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
29
+ initialComments?: IComment[];
30
+ setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
31
+ onCommentReply?: (activeCommentId: string, reply: IComment) => void;
32
+ onNewComment?: (newComment: IComment) => void;
33
+ onResolveComment?: (activeCommentId: string) => void;
34
+ onUnresolveComment?: (activeCommentId: string) => void;
35
+ onDeleteComment?: (activeCommentId: string) => void;
19
36
  showTOC?: boolean;
20
37
  setShowTOC?: React.Dispatch<SetStateAction<boolean>>;
21
38
  proExtensions?: Record<string, Extension | any>;
@@ -40,10 +57,11 @@ export interface DdocProps {
40
57
  initialContent?: JSONContent | string | string[] | null;
41
58
  walletAddress?: string | null;
42
59
  username?: string | null;
60
+ setUsername?: React.Dispatch<SetStateAction<string>>;
43
61
  renderNavbar?: ({ editor }: {
44
62
  editor: JSONContent;
45
63
  }) => JSX.Element;
46
- onChange?: (changes: Data['editorJSONData']) => void;
64
+ onChange?: (updatedDocContent: Data['editorJSONData'], updateChunk: string) => void;
47
65
  onCollaboratorChange?: (collaborators: undefined | IDocCollabUsers[]) => void;
48
66
  onTextSelection?: (data: IEditorSelectionData) => void;
49
67
  onCommentInteraction?: (data: IEditorSelectionData) => void;
@@ -78,11 +96,11 @@ export interface IEditorSelectionData {
78
96
  isHighlightedYellow: boolean;
79
97
  }
80
98
  export interface Data {
81
- editorJSONData: JSONContent;
99
+ editorJSONData: string | JSONContent;
82
100
  }
83
101
  export interface IUser {
84
102
  name: string;
85
103
  color: string;
86
104
  isEns: boolean;
87
105
  }
88
- export {};
106
+ export { type IComment };
@@ -8,6 +8,9 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableColl
8
8
  connect: (username: string | null | undefined, isEns?: boolean) => () => void;
9
9
  ydoc: Y.Doc;
10
10
  refreshYjsIndexedDbProvider: () => Promise<void>;
11
+ activeCommentId: string | null;
12
+ setActiveCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
13
+ focusCommentWithActiveId: (id: string) => void;
11
14
  slides: string[];
12
15
  setSlides: import('react').Dispatch<import('react').SetStateAction<string[]>>;
13
16
  tocItems: any[];
@@ -0,0 +1,2 @@
1
+ export declare const nameFormatter: (username: string) => string;
2
+ export declare const dateFormatter: (date: Date) => string | import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export declare const useResponsive: () => {
2
+ isBelow1024px: boolean;
3
+ isBelow1280px: boolean;
4
+ isMobileScreen: boolean;
5
+ isNativeMobile: boolean;
6
+ isIOS: boolean;
7
+ };