@fileverse-dev/ddoc 3.0.55 → 3.0.56-patch-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.
- package/README.md +5 -1
- package/dist/index.es.js +41910 -39114
- package/dist/package/components/editor-toolbar.d.ts +6 -1
- package/dist/package/components/editor-utils.d.ts +2 -2
- package/dist/package/components/export-modal.d.ts +22 -0
- package/dist/package/components/import-export-button.d.ts +8 -1
- package/dist/package/components/inline-comment/context/comment-context.d.ts +1 -1
- package/dist/package/components/inline-comment/context/types.d.ts +9 -5
- package/dist/package/components/preview-export-trigger.d.ts +24 -0
- package/dist/package/components/tabs/confirm-delete-modal.d.ts +19 -0
- package/dist/package/components/tabs/document-mobile-tab-panel.d.ts +27 -0
- package/dist/package/components/tabs/document-tabs-sidebar.d.ts +60 -0
- package/dist/package/components/tabs/tab-emoji-picker.d.ts +16 -0
- package/dist/package/components/tabs/tab-item.d.ts +58 -0
- package/dist/package/components/tabs/utils/tab-utils.d.ts +21 -0
- package/dist/package/components/toc/document-outline-toc-panel.d.ts +5 -0
- package/dist/package/components/toc/document-outline.d.ts +1 -1
- package/dist/package/components/toc/memorized-toc.d.ts +3 -0
- package/dist/package/components/toc/types.d.ts +25 -2
- package/dist/package/extensions/comment/comment.d.ts +1 -0
- package/dist/package/hooks/use-ddoc-export.d.ts +24 -0
- package/dist/package/hooks/use-tab-editor.d.ts +62 -0
- package/dist/package/hooks/use-tab-manager.d.ts +32 -0
- package/dist/package/hooks/use-tab-metadata-history.d.ts +14 -0
- package/dist/package/hooks/use-yjs-setup.d.ts +27 -0
- package/dist/package/sync-local/useSyncMachine.d.ts +1 -2
- package/dist/package/types.d.ts +21 -4
- package/dist/package/use-ddoc-editor.d.ts +29 -12
- package/dist/style.css +1 -1
- package/package.json +5 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Editor } from '@tiptap/react';
|
|
3
3
|
import { IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
|
|
4
|
+
import { Tab } from './tabs/utils/tab-utils';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
import * as Y from 'yjs';
|
|
7
|
+
declare const TiptapToolBar: ({ editor, onError, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onDocxImport, isLoading, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, }: {
|
|
6
8
|
editor: Editor | null;
|
|
7
9
|
onError?: (errorString: string) => void;
|
|
8
10
|
zoomLevel: string;
|
|
@@ -23,5 +25,8 @@ declare const TiptapToolBar: ({ editor, onError, zoomLevel, setZoomLevel, isNavb
|
|
|
23
25
|
file: File;
|
|
24
26
|
}>;
|
|
25
27
|
isConnected?: boolean;
|
|
28
|
+
tabs: Tab[];
|
|
29
|
+
ydoc: Y.Doc;
|
|
30
|
+
onRegisterExportTrigger?: ((trigger: ((format?: string, name?: string) => void) | null) => void) | undefined;
|
|
26
31
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
27
32
|
export default TiptapToolBar;
|
|
@@ -6,7 +6,7 @@ import { IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
|
|
|
6
6
|
export interface IEditorToolElement {
|
|
7
7
|
icon: any;
|
|
8
8
|
title: string;
|
|
9
|
-
onClick: () => void;
|
|
9
|
+
onClick: (name?: string) => void;
|
|
10
10
|
isActive: boolean;
|
|
11
11
|
group?: string;
|
|
12
12
|
isNew?: boolean;
|
|
@@ -55,7 +55,7 @@ export declare const IMG_UPLOAD_SETTINGS: {
|
|
|
55
55
|
errorMsg: string;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
export declare const useEditorToolbar: ({ editor, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn,
|
|
58
|
+
export declare const useEditorToolbar: ({ editor, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, }: {
|
|
59
59
|
editor: Editor | null;
|
|
60
60
|
onError?: (errorString: string) => void;
|
|
61
61
|
ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ExportFormatOption {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
interface ExportTabOption {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
interface ExportAsModalProps {
|
|
10
|
+
open: boolean;
|
|
11
|
+
onOpenChange: (open: boolean) => void;
|
|
12
|
+
onExport?: (data: {
|
|
13
|
+
format: string;
|
|
14
|
+
tab: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
formatOptions: ExportFormatOption[];
|
|
17
|
+
tabOptions: ExportTabOption[];
|
|
18
|
+
initialFormat?: string;
|
|
19
|
+
initialTab?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const ExportAsModal: ({ open, onOpenChange, onExport, formatOptions, tabOptions, initialFormat, initialTab, }: ExportAsModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { IEditorToolElement } from './editor-utils';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { Tab } from './tabs/utils/tab-utils';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, setDropdownOpen, editor, tabs, ydoc, onRegisterExportTrigger, }: {
|
|
4
7
|
fileExportsOpen: boolean;
|
|
5
8
|
setFileExportsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
9
|
exportOptions: (IEditorToolElement | null)[];
|
|
7
10
|
importOptions: (IEditorToolElement | null)[];
|
|
8
11
|
setDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
+
editor: Editor | null;
|
|
13
|
+
tabs: Tab[];
|
|
14
|
+
ydoc: Y.Doc;
|
|
15
|
+
onRegisterExportTrigger?: ((trigger: ((format?: string, name?: string) => void) | null) => void) | undefined;
|
|
9
16
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
17
|
export { ImportExportButton };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CommentContextType, CommentProviderProps } from './types';
|
|
2
2
|
|
|
3
|
-
export declare const CommentProvider: ({ children, editor, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const CommentProvider: ({ children, editor, ydoc, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, activeTabId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const useComments: () => CommentContextType;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
2
|
import { IComment } from '../../../extensions/comment';
|
|
3
3
|
import { SetStateAction } from 'react';
|
|
4
|
-
import { CommentAccountProps } from '../../../types';
|
|
4
|
+
import { CommentAccountProps, CommentMutationMeta } from '../../../types';
|
|
5
5
|
import { EnsStatus } from '../types';
|
|
6
6
|
|
|
7
|
+
import * as Y from 'yjs';
|
|
7
8
|
export interface CommentContextType extends CommentAccountProps {
|
|
8
9
|
comments: IComment[];
|
|
9
10
|
setComments: React.Dispatch<SetStateAction<IComment[]>>;
|
|
@@ -50,6 +51,7 @@ export interface CommentContextType extends CommentAccountProps {
|
|
|
50
51
|
isCommentActive: boolean;
|
|
51
52
|
isCommentResolved: boolean;
|
|
52
53
|
ensResolutionUrl: string;
|
|
54
|
+
activeTabId: string;
|
|
53
55
|
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
54
56
|
onComment?: () => void;
|
|
55
57
|
setCommentDrawerOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -67,17 +69,19 @@ export interface CommentContextType extends CommentAccountProps {
|
|
|
67
69
|
export interface CommentProviderProps extends CommentAccountProps {
|
|
68
70
|
children: React.ReactNode;
|
|
69
71
|
editor: Editor;
|
|
72
|
+
ydoc: Y.Doc;
|
|
70
73
|
initialComments?: IComment[];
|
|
71
74
|
setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
|
|
72
75
|
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
73
|
-
onNewComment?: (newComment: IComment) => void;
|
|
74
|
-
onResolveComment?: (activeCommentId: string) => void;
|
|
75
|
-
onUnresolveComment?: (activeCommentId: string) => void;
|
|
76
|
-
onDeleteComment?: (activeCommentId: string) => void;
|
|
76
|
+
onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
|
|
77
|
+
onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
78
|
+
onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
79
|
+
onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
77
80
|
username: string | null;
|
|
78
81
|
setUsername?: React.Dispatch<SetStateAction<string>>;
|
|
79
82
|
activeCommentId: string | null;
|
|
80
83
|
setActiveCommentId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
84
|
+
activeTabId: string;
|
|
81
85
|
focusCommentWithActiveId: (id: string) => void;
|
|
82
86
|
ensResolutionUrl: string;
|
|
83
87
|
onInlineComment?: () => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { Tab } from './tabs/utils/tab-utils';
|
|
3
|
+
import { DdocProps } from '../types';
|
|
4
|
+
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
interface PreviewModeExportTriggerProps {
|
|
7
|
+
editor: Editor | null;
|
|
8
|
+
ydoc: Y.Doc;
|
|
9
|
+
tabs: Tab[];
|
|
10
|
+
onRegisterExportTrigger?: (trigger: ((format?: string, name?: string) => void) | null) => void;
|
|
11
|
+
onError?: (errorString: string) => void;
|
|
12
|
+
ipfsImageUploadFn?: DdocProps['ipfsImageUploadFn'];
|
|
13
|
+
onMarkdownExport?: DdocProps['onMarkdownExport'];
|
|
14
|
+
onMarkdownImport?: DdocProps['onMarkdownImport'];
|
|
15
|
+
onPdfExport?: DdocProps['onPdfExport'];
|
|
16
|
+
onHtmlExport?: DdocProps['onHtmlExport'];
|
|
17
|
+
onTxtExport?: DdocProps['onTxtExport'];
|
|
18
|
+
ipfsImageFetchFn?: DdocProps['ipfsImageFetchFn'];
|
|
19
|
+
onDocxImport?: DdocProps['onDocxImport'];
|
|
20
|
+
fetchV1ImageFn?: DdocProps['fetchV1ImageFn'];
|
|
21
|
+
isConnected?: DdocProps['isConnected'];
|
|
22
|
+
}
|
|
23
|
+
declare const PreviewModeExportTrigger: ({ editor, ydoc, tabs, onRegisterExportTrigger, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, isConnected, }: PreviewModeExportTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export { PreviewModeExportTrigger };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface IConfirmDeleteModalProps {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
documentTitle: string;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
text?: string | ReactNode;
|
|
10
|
+
title?: string;
|
|
11
|
+
overlayClasses?: string;
|
|
12
|
+
noOverlay?: boolean;
|
|
13
|
+
primaryLabel?: string;
|
|
14
|
+
secondaryLabel?: string;
|
|
15
|
+
hasCloseIcon?: boolean;
|
|
16
|
+
hideTitleIcon?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const ConfirmDeleteModal: ({ onClose, onConfirm, isOpen, isLoading, title, overlayClasses, noOverlay, hasCloseIcon, primaryLabel, hideTitleIcon, }: IConfirmDeleteModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { DocumentOutlineProps } from '../toc/types';
|
|
3
|
+
import { Tab } from './utils/tab-utils';
|
|
4
|
+
|
|
5
|
+
export interface DocumentMobileTabPanelProps {
|
|
6
|
+
tabs: Tab[];
|
|
7
|
+
setTabs: Dispatch<SetStateAction<Tab[]>>;
|
|
8
|
+
activeTabId: string;
|
|
9
|
+
setActiveTabId: (id: string) => void;
|
|
10
|
+
editor: DocumentOutlineProps['editor'];
|
|
11
|
+
items: DocumentOutlineProps['items'];
|
|
12
|
+
setItems: DocumentOutlineProps['setItems'];
|
|
13
|
+
orientation?: DocumentOutlineProps['orientation'];
|
|
14
|
+
renameTab: (tabId: string, payload: {
|
|
15
|
+
newName?: string;
|
|
16
|
+
emoji?: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
createTab: () => void;
|
|
19
|
+
duplicateTab: (tabId: string) => void;
|
|
20
|
+
deleteTab?: (tabId: string) => void;
|
|
21
|
+
tabCommentCounts: Record<string, number>;
|
|
22
|
+
isPreviewMode: boolean;
|
|
23
|
+
tabConfig?: DocumentOutlineProps['tabConfig'];
|
|
24
|
+
isVersionHistoryMode: boolean;
|
|
25
|
+
isConnected?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const DocumentMobileTabPanel: ({ tabs, activeTabId, setActiveTabId, editor, items, setItems, orientation, renameTab, createTab, duplicateTab, deleteTab, tabCommentCounts, isPreviewMode, tabConfig, isVersionHistoryMode, isConnected, }: DocumentMobileTabPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DocumentOutlineProps } from '../toc/types';
|
|
3
|
+
import { Tab } from './utils/tab-utils';
|
|
4
|
+
import { Editor } from '@tiptap/core';
|
|
5
|
+
|
|
6
|
+
import * as Y from 'yjs';
|
|
7
|
+
export interface DocumentTabsSidebarProps {
|
|
8
|
+
tabs: Tab[];
|
|
9
|
+
setTabs: React.Dispatch<React.SetStateAction<Tab[]>>;
|
|
10
|
+
activeTabId: string;
|
|
11
|
+
setActiveTabId: (id: string) => void;
|
|
12
|
+
showTOC: DocumentOutlineProps['showTOC'];
|
|
13
|
+
setShowTOC: DocumentOutlineProps['setShowTOC'];
|
|
14
|
+
hasToC: DocumentOutlineProps['hasToC'];
|
|
15
|
+
isPreviewMode: DocumentOutlineProps['isPreviewMode'];
|
|
16
|
+
editor: DocumentOutlineProps['editor'];
|
|
17
|
+
items: DocumentOutlineProps['items'];
|
|
18
|
+
setItems: DocumentOutlineProps['setItems'];
|
|
19
|
+
orientation?: DocumentOutlineProps['orientation'];
|
|
20
|
+
createTab: () => void;
|
|
21
|
+
renameTab: (tabId: string, payload: {
|
|
22
|
+
newName?: string;
|
|
23
|
+
emoji?: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
duplicateTab: (tabId: string) => void;
|
|
26
|
+
orderTab: (destinationTabId: string, activeTabId: string) => void;
|
|
27
|
+
ydoc: Y.Doc;
|
|
28
|
+
tabCommentCounts: Record<string, number>;
|
|
29
|
+
tabSectionContainer?: HTMLElement;
|
|
30
|
+
isVersionHistoryMode?: boolean;
|
|
31
|
+
tabConfig?: DocumentOutlineProps['tabConfig'];
|
|
32
|
+
deleteTab?: (tabId: string) => void;
|
|
33
|
+
isConnected?: boolean;
|
|
34
|
+
}
|
|
35
|
+
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 DdocTab: ({ tab, tabIndex, tabCount, handleEmojiChange, handleNameChange, onClick, editor, tocItem, setTocItems, orientation, activeTabId, duplicateTab, commentCount, moveTabUp, moveTabDown, isPreviewMode, isVersionHistoryMode, tabConfig, onDelete, showOutline, onShowOutlineChange, isConnected, }: {
|
|
38
|
+
tab: Tab;
|
|
39
|
+
tabIndex: number;
|
|
40
|
+
tabCount: number;
|
|
41
|
+
handleNameChange: (tabId: string, nextName: string, nextEmoji?: string) => void;
|
|
42
|
+
handleEmojiChange: (tabId: string, nextEmoji: string) => void;
|
|
43
|
+
onClick: () => void;
|
|
44
|
+
editor: Editor;
|
|
45
|
+
tocItem: DocumentOutlineProps["items"];
|
|
46
|
+
setTocItems: DocumentOutlineProps["setItems"];
|
|
47
|
+
orientation: DocumentOutlineProps["orientation"];
|
|
48
|
+
activeTabId: string;
|
|
49
|
+
duplicateTab: (tabId: string) => void;
|
|
50
|
+
commentCount: number;
|
|
51
|
+
moveTabUp: () => void;
|
|
52
|
+
moveTabDown: () => void;
|
|
53
|
+
isPreviewMode: boolean;
|
|
54
|
+
isVersionHistoryMode?: boolean;
|
|
55
|
+
tabConfig?: DocumentOutlineProps["tabConfig"];
|
|
56
|
+
onDelete?: (tab: Tab) => void;
|
|
57
|
+
showOutline: boolean;
|
|
58
|
+
onShowOutlineChange: (value: boolean) => void;
|
|
59
|
+
isConnected?: boolean;
|
|
60
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EmojiPickerListCategoryHeaderProps, EmojiPickerListEmojiProps, EmojiPickerListRowProps, EmojiPicker as EmojiPickerPrimitive } from 'frimousse';
|
|
2
|
+
|
|
3
|
+
export declare const TabEmojiPicker: ({ emoji, setEmoji, isEditing, openPickerTrigger, disableEmoji, }: {
|
|
4
|
+
emoji: string;
|
|
5
|
+
setEmoji: (emoji: string) => void;
|
|
6
|
+
isEditing: boolean;
|
|
7
|
+
openPickerTrigger?: number;
|
|
8
|
+
disableEmoji: boolean;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function EmojiPicker({ className, ...props }: React.ComponentProps<typeof EmojiPickerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function EmojiPickerSearch({ className, ...props }: React.ComponentProps<typeof EmojiPickerPrimitive.Search>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function EmojiPickerRow({ children, ...props }: EmojiPickerListRowProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function EmojiPickerEmoji({ emoji, className, ...props }: EmojiPickerListEmojiProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function EmojiPickerCategoryHeader({ category, ...props }: EmojiPickerListCategoryHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function EmojiPickerContent({ className, ...props }: React.ComponentProps<typeof EmojiPickerPrimitive.Viewport>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function EmojiPickerFooter({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ComponentProps, HTMLAttributes } from 'react';
|
|
2
|
+
import { LucideIcon } from '@fileverse/ui';
|
|
3
|
+
|
|
4
|
+
export interface TabItemProps {
|
|
5
|
+
tabId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
emoji: string;
|
|
8
|
+
commentCount?: number;
|
|
9
|
+
onNameChange: (name: string, emoji?: string) => void;
|
|
10
|
+
onEmojiChange: (emoji: string) => void;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
onDuplicate?: (id: string) => void;
|
|
14
|
+
dragHandleProps?: HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
hideContentMenu?: boolean;
|
|
16
|
+
showOutline?: boolean;
|
|
17
|
+
handleShowOutline?: (value: boolean) => void;
|
|
18
|
+
canMoveUp?: boolean;
|
|
19
|
+
canMoveDown?: boolean;
|
|
20
|
+
onMoveUp?: () => void;
|
|
21
|
+
onMoveDown?: () => void;
|
|
22
|
+
isPreviewMode: boolean;
|
|
23
|
+
isVersionHistoryMode?: boolean;
|
|
24
|
+
onCopyLink?: () => void;
|
|
25
|
+
onDelete?: () => void;
|
|
26
|
+
isConnected?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface SortableTabItemProps extends Omit<TabItemProps, 'dragHandleProps'> {
|
|
29
|
+
id: string;
|
|
30
|
+
}
|
|
31
|
+
interface TabContextMenuItem {
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
icon: ComponentProps<typeof LucideIcon>['name'];
|
|
35
|
+
onSelect?: () => void;
|
|
36
|
+
visible?: boolean;
|
|
37
|
+
closeOnSelect?: boolean;
|
|
38
|
+
textClassName?: string;
|
|
39
|
+
iconStroke?: string;
|
|
40
|
+
tooltipText?: string;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface TabContextMenuProps {
|
|
44
|
+
sections: TabContextMenuItem[][];
|
|
45
|
+
popoverSide?: 'top' | 'bottom';
|
|
46
|
+
popoverClassName?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const SortableTabItem: (props: SortableTabItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare const TabItem: ({ tabId, name, emoji, commentCount, onNameChange, onEmojiChange, onClick, isActive, onDuplicate, dragHandleProps, hideContentMenu, showOutline, handleShowOutline, canMoveUp, canMoveDown, onMoveUp, onMoveDown, isPreviewMode, isVersionHistoryMode, onCopyLink, onDelete, isConnected, }: TabItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const TabDragPreview: ({ name, emoji, }: {
|
|
51
|
+
name: string;
|
|
52
|
+
emoji: string;
|
|
53
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export declare const TabContextMenuAction: ({ item, }: {
|
|
55
|
+
item: TabContextMenuItem;
|
|
56
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export declare const TabContextMenu: ({ sections, popoverSide, popoverClassName, }: TabContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
export interface Tab {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
emoji: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_TAB_ID = "default";
|
|
8
|
+
export declare const DEFAULT_TAB_NAME = "Tab 1";
|
|
9
|
+
export declare function deriveTabsFromEncodedState(yjsEncodedState: string, doc: Y.Doc, options?: {
|
|
10
|
+
createDefaultTabIfMissing?: boolean;
|
|
11
|
+
}): {
|
|
12
|
+
tabList: Tab[];
|
|
13
|
+
activeTabId: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function getTabsYdocNodes(doc: Y.Doc): {
|
|
16
|
+
root: Y.Map<unknown>;
|
|
17
|
+
order: Y.Array<string>;
|
|
18
|
+
tabs: Y.Map<Y.Map<string | null>>;
|
|
19
|
+
activeTab: Y.Text;
|
|
20
|
+
};
|
|
21
|
+
export declare function cloneFragmentContent(fragment: Y.XmlFragment): (Y.XmlElement | Y.XmlText)[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DocumentOutlineProps } from './types';
|
|
2
|
+
|
|
3
|
+
type DocumentOutlineTOCPanelProps = Pick<DocumentOutlineProps, 'editor' | 'hasToC' | 'items' | 'setItems' | 'showTOC' | 'setShowTOC' | 'isPreviewMode' | 'orientation'>;
|
|
4
|
+
export declare const DocumentOutlineTOCPanel: ({ editor, hasToC, items, setItems, showTOC, setShowTOC, isPreviewMode, orientation, }: DocumentOutlineTOCPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DocumentOutlineProps } from './types';
|
|
2
2
|
|
|
3
|
-
export declare const DocumentOutline: ({ editor, hasToC, items, setItems, showTOC, setShowTOC, isPreviewMode, orientation, }: DocumentOutlineProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const DocumentOutline: ({ editor, hasToC, items, setItems, showTOC, setShowTOC, isPreviewMode, orientation, tabs, setTabs, activeTabId, setActiveTabId, createTab, renameTab, duplicateTab, orderTab, ydoc, tabCommentCounts, tabSectionContainer, isVersionHistoryMode, tabConfig, deleteTab, isConnected, }: DocumentOutlineProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
|
-
import { SetStateAction } from 'react';
|
|
2
|
+
import { default as React, Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import { Tab } from '../tabs/utils/tab-utils';
|
|
3
4
|
|
|
5
|
+
import * as Y from 'yjs';
|
|
4
6
|
export interface ToCItemType {
|
|
5
7
|
id: string;
|
|
6
8
|
level: number;
|
|
@@ -27,7 +29,28 @@ export interface DocumentOutlineProps {
|
|
|
27
29
|
items: ToCItemType[];
|
|
28
30
|
setItems: (items: ToCItemType[] | ((prev: ToCItemType[]) => ToCItemType[])) => void;
|
|
29
31
|
showTOC: boolean | undefined;
|
|
30
|
-
setShowTOC:
|
|
32
|
+
setShowTOC: Dispatch<SetStateAction<boolean>> | undefined;
|
|
31
33
|
isPreviewMode: boolean;
|
|
32
34
|
orientation?: 'portrait' | 'landscape';
|
|
35
|
+
tabs: Tab[];
|
|
36
|
+
setTabs: Dispatch<SetStateAction<Tab[]>>;
|
|
37
|
+
activeTabId: string;
|
|
38
|
+
setActiveTabId: (id: string) => void;
|
|
39
|
+
createTab: () => void;
|
|
40
|
+
renameTab: (tabId: string, payload: {
|
|
41
|
+
newName?: string;
|
|
42
|
+
emoji?: string;
|
|
43
|
+
}) => void;
|
|
44
|
+
duplicateTab: (tabId: string) => void;
|
|
45
|
+
orderTab: (destinationTabId: string, activeTabId: string) => void;
|
|
46
|
+
ydoc: Y.Doc;
|
|
47
|
+
tabCommentCounts: Record<string, number>;
|
|
48
|
+
tabSectionContainer?: HTMLElement;
|
|
49
|
+
isVersionHistoryMode?: boolean;
|
|
50
|
+
tabConfig?: {
|
|
51
|
+
onCopyTabLink?: (tabId: string) => void;
|
|
52
|
+
defaultTabId?: string;
|
|
53
|
+
};
|
|
54
|
+
deleteTab?: (tabId: string) => void;
|
|
55
|
+
isConnected?: boolean;
|
|
33
56
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { IEditorToolElement } from '../components/editor-utils';
|
|
3
|
+
import { Tab } from '../components/tabs/utils/tab-utils';
|
|
4
|
+
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
interface UseDdocExportArgs {
|
|
7
|
+
editor: Editor | null;
|
|
8
|
+
tabs: Tab[];
|
|
9
|
+
ydoc: Y.Doc;
|
|
10
|
+
exportOptions: (IEditorToolElement | null)[];
|
|
11
|
+
}
|
|
12
|
+
declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExportArgs) => {
|
|
13
|
+
getOptionFormat: (title: string) => "" | "md" | "pdf" | "html" | "txt";
|
|
14
|
+
formatSelectOptions: {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
handleExport: ({ format, tab, name }: {
|
|
19
|
+
format: string;
|
|
20
|
+
tab: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
};
|
|
24
|
+
export { useDdocExport };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
|
+
import { DdocProps } from '../types';
|
|
3
|
+
import { AnyExtension, Editor } from '@tiptap/react';
|
|
4
|
+
import { ToCItemType } from '../components/toc/types';
|
|
5
|
+
import { IConnectConf } from '../sync-local/useSyncMachine';
|
|
6
|
+
|
|
7
|
+
import * as Y from 'yjs';
|
|
8
|
+
interface UseTabEditorArgs {
|
|
9
|
+
ydoc: Y.Doc;
|
|
10
|
+
isVersionMode?: boolean;
|
|
11
|
+
hasTabState?: boolean;
|
|
12
|
+
versionId?: string;
|
|
13
|
+
isPreviewMode?: boolean;
|
|
14
|
+
initialContent: DdocProps['initialContent'];
|
|
15
|
+
enableCollaboration?: boolean;
|
|
16
|
+
collabConfig?: DdocProps['collabConfig'];
|
|
17
|
+
isReady?: boolean;
|
|
18
|
+
awareness?: any;
|
|
19
|
+
disableInlineComment?: boolean;
|
|
20
|
+
onCommentInteraction?: DdocProps['onCommentInteraction'];
|
|
21
|
+
onError?: DdocProps['onError'];
|
|
22
|
+
ipfsImageUploadFn?: DdocProps['ipfsImageUploadFn'];
|
|
23
|
+
metadataProxyUrl?: string;
|
|
24
|
+
onCopyHeadingLink?: DdocProps['onCopyHeadingLink'];
|
|
25
|
+
ipfsImageFetchFn?: DdocProps['ipfsImageFetchFn'];
|
|
26
|
+
fetchV1ImageFn?: DdocProps['fetchV1ImageFn'];
|
|
27
|
+
isConnected?: boolean;
|
|
28
|
+
activeModel?: DdocProps['activeModel'];
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
isAIAgentEnabled?: boolean;
|
|
31
|
+
setCharacterCount?: DdocProps['setCharacterCount'];
|
|
32
|
+
setWordCount?: DdocProps['setWordCount'];
|
|
33
|
+
setIsContentLoading: Dispatch<SetStateAction<boolean>>;
|
|
34
|
+
setIsCollabContentLoading: Dispatch<SetStateAction<boolean>>;
|
|
35
|
+
unFocused?: boolean;
|
|
36
|
+
zoomLevel?: string;
|
|
37
|
+
isPresentationMode?: boolean;
|
|
38
|
+
onInvalidContentError?: DdocProps['onInvalidContentError'];
|
|
39
|
+
ignoreCorruptedData?: boolean;
|
|
40
|
+
onCollaboratorChange?: DdocProps['onCollaboratorChange'];
|
|
41
|
+
onConnect: (connectConfig: IConnectConf) => void;
|
|
42
|
+
hasCollabContentInitialised?: boolean;
|
|
43
|
+
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
44
|
+
externalExtensions?: Record<string, AnyExtension>;
|
|
45
|
+
isContentLoading?: boolean;
|
|
46
|
+
activeTabId: string;
|
|
47
|
+
theme?: 'dark' | 'light';
|
|
48
|
+
editorRef?: MutableRefObject<Editor | null>;
|
|
49
|
+
}
|
|
50
|
+
export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionId, isPreviewMode, initialContent, enableCollaboration, collabConfig, isReady, awareness, disableInlineComment, onCommentInteraction, onError, ipfsImageUploadFn, metadataProxyUrl, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, setCharacterCount, setWordCount, setIsContentLoading, setIsCollabContentLoading, unFocused, zoomLevel, isPresentationMode, onInvalidContentError, ignoreCorruptedData, onCollaboratorChange, onConnect, hasCollabContentInitialised, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, theme, editorRef, }: UseTabEditorArgs) => {
|
|
51
|
+
editor: Editor | null;
|
|
52
|
+
ref: import('react').RefObject<HTMLDivElement>;
|
|
53
|
+
slides: string[];
|
|
54
|
+
setSlides: Dispatch<SetStateAction<string[]>>;
|
|
55
|
+
tocItems: ToCItemType[];
|
|
56
|
+
setTocItems: Dispatch<SetStateAction<ToCItemType[]>>;
|
|
57
|
+
activeCommentId: string | null;
|
|
58
|
+
setActiveCommentId: Dispatch<SetStateAction<string | null>>;
|
|
59
|
+
focusCommentWithActiveId: (id: string) => void;
|
|
60
|
+
isContentLoading: boolean | undefined;
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { DdocProps } from '../types';
|
|
3
|
+
import { Tab } from '../components/tabs/utils/tab-utils';
|
|
4
|
+
import * as Y from 'yjs';
|
|
5
|
+
interface UseTabManagerArgs {
|
|
6
|
+
ydoc: Y.Doc;
|
|
7
|
+
initialContent: DdocProps['initialContent'];
|
|
8
|
+
enableCollaboration: DdocProps['enableCollaboration'];
|
|
9
|
+
isDDocOwner: boolean;
|
|
10
|
+
createDefaultTabIfMissing: boolean;
|
|
11
|
+
shouldSyncActiveTab: boolean;
|
|
12
|
+
defaultTabId?: string;
|
|
13
|
+
onVersionHistoryActiveTabChange?: (tabId: string | null) => void;
|
|
14
|
+
getEditor?: () => Editor | null;
|
|
15
|
+
}
|
|
16
|
+
export declare const getNewTabId: () => string;
|
|
17
|
+
export declare const useTabManager: ({ ydoc, initialContent, enableCollaboration, isDDocOwner, createDefaultTabIfMissing, shouldSyncActiveTab, defaultTabId, onVersionHistoryActiveTabChange, getEditor, }: UseTabManagerArgs) => {
|
|
18
|
+
tabs: Tab[];
|
|
19
|
+
hasTabState: boolean;
|
|
20
|
+
activeTabId: string;
|
|
21
|
+
setTabs: import('react').Dispatch<import('react').SetStateAction<Tab[]>>;
|
|
22
|
+
setActiveTabId: (id: string) => void;
|
|
23
|
+
createTab: () => string;
|
|
24
|
+
deleteTab: (tabId: string) => void;
|
|
25
|
+
renameTab: (tabId: string, { newName, emoji }: {
|
|
26
|
+
newName?: string;
|
|
27
|
+
emoji?: string;
|
|
28
|
+
}) => void;
|
|
29
|
+
duplicateTab: (tabId: string) => string | undefined;
|
|
30
|
+
orderTab: (destinationTabId: string, movedTabId: string) => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
interface ApplyRenameArgs {
|
|
3
|
+
tabId: string;
|
|
4
|
+
newName?: string;
|
|
5
|
+
emoji?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useTabMetadataHistory: (ydoc: Y.Doc) => {
|
|
8
|
+
applyRename: ({ tabId, newName, emoji }: ApplyRenameArgs) => {
|
|
9
|
+
tabNotFound: boolean;
|
|
10
|
+
};
|
|
11
|
+
undo: () => boolean;
|
|
12
|
+
redo: () => boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/react';
|
|
2
|
+
import { DdocProps } from '../types';
|
|
3
|
+
import * as Y from 'yjs';
|
|
4
|
+
interface UseYjsSetupArgs {
|
|
5
|
+
onChange?: (updatedDocContent: string | JSONContent, updateChunk: string) => void;
|
|
6
|
+
enableIndexeddbSync?: boolean;
|
|
7
|
+
ddocId?: string;
|
|
8
|
+
enableCollaboration?: boolean;
|
|
9
|
+
onIndexedDbError?: (error: Error) => void;
|
|
10
|
+
onCollabError?: DdocProps['onCollabError'];
|
|
11
|
+
onCollaborationConnectCallback?: DdocProps['onCollaborationConnectCallback'];
|
|
12
|
+
onCollaborationCommit?: DdocProps['onCollaborationCommit'];
|
|
13
|
+
onFetchCommitContent?: DdocProps['onFetchCommitContent'];
|
|
14
|
+
onCollabSessionTermination?: () => void;
|
|
15
|
+
onUnMergedUpdates?: (state: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useYjsSetup: ({ onChange, enableIndexeddbSync, ddocId, enableCollaboration, onIndexedDbError, onCollabError, onCollaborationConnectCallback, onCollaborationCommit, onFetchCommitContent, onCollabSessionTermination, onUnMergedUpdates, }: UseYjsSetupArgs) => {
|
|
18
|
+
ydoc: Y.Doc;
|
|
19
|
+
onConnect: (connectConfig: import('../sync-local/useSyncMachine').IConnectConf) => void;
|
|
20
|
+
isReady: boolean;
|
|
21
|
+
terminateSession: () => void;
|
|
22
|
+
awareness: any;
|
|
23
|
+
hasCollabContentInitialised: boolean;
|
|
24
|
+
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
25
|
+
refreshYjsIndexedDbProvider: () => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SyncMachineContext } from '.';
|
|
2
2
|
|
|
3
|
-
interface IConnectConf {
|
|
3
|
+
export interface IConnectConf {
|
|
4
4
|
username?: string;
|
|
5
5
|
roomKey: string;
|
|
6
6
|
roomId: string;
|
|
@@ -36,4 +36,3 @@ export declare const useSyncMachine: (config: Partial<SyncMachineContext>) => {
|
|
|
36
36
|
data: any;
|
|
37
37
|
}, import('xstate').BaseActionObject, import('xstate').ServiceMap>>;
|
|
38
38
|
};
|
|
39
|
-
export {};
|