@fileverse-dev/ddoc 3.0.54 → 3.0.55-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.
Files changed (30) hide show
  1. package/README.md +5 -1
  2. package/dist/index.es.js +42115 -39440
  3. package/dist/package/components/editor-toolbar.d.ts +6 -1
  4. package/dist/package/components/editor-utils.d.ts +1 -1
  5. package/dist/package/components/export-modal.d.ts +22 -0
  6. package/dist/package/components/import-export-button.d.ts +8 -1
  7. package/dist/package/components/inline-comment/context/comment-context.d.ts +1 -1
  8. package/dist/package/components/inline-comment/context/types.d.ts +2 -0
  9. package/dist/package/components/preview-export-trigger.d.ts +24 -0
  10. package/dist/package/components/tabs/confirm-delete-modal.d.ts +19 -0
  11. package/dist/package/components/tabs/document-mobile-tab-panel.d.ts +27 -0
  12. package/dist/package/components/tabs/document-tabs-sidebar.d.ts +61 -0
  13. package/dist/package/components/tabs/tab-emoji-picker.d.ts +16 -0
  14. package/dist/package/components/tabs/tab-item.d.ts +58 -0
  15. package/dist/package/components/tabs/utils/tab-utils.d.ts +21 -0
  16. package/dist/package/components/toc/document-outline-toc-panel.d.ts +5 -0
  17. package/dist/package/components/toc/document-outline.d.ts +1 -1
  18. package/dist/package/components/toc/memorized-toc.d.ts +3 -0
  19. package/dist/package/components/toc/types.d.ts +25 -2
  20. package/dist/package/extensions/comment/comment.d.ts +1 -0
  21. package/dist/package/hooks/use-ddoc-export.d.ts +24 -0
  22. package/dist/package/hooks/use-tab-editor.d.ts +61 -0
  23. package/dist/package/hooks/use-tab-manager.d.ts +29 -0
  24. package/dist/package/hooks/use-tab-metadata-history.d.ts +14 -0
  25. package/dist/package/hooks/use-yjs-setup.d.ts +27 -0
  26. package/dist/package/sync-local/useSyncMachine.d.ts +1 -2
  27. package/dist/package/types.d.ts +10 -0
  28. package/dist/package/use-ddoc-editor.d.ts +28 -12
  29. package/dist/style.css +1 -1
  30. package/package.json +6 -2
@@ -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
- declare const TiptapToolBar: ({ editor, onError, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onDocxImport, isLoading, ipfsImageFetchFn, fetchV1ImageFn, isConnected, }: {
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;
@@ -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
- declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, setDropdownOpen, }: {
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, 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;
@@ -50,6 +50,7 @@ export interface CommentContextType extends CommentAccountProps {
50
50
  isCommentActive: boolean;
51
51
  isCommentResolved: boolean;
52
52
  ensResolutionUrl: string;
53
+ activeTabId: string;
53
54
  onCommentReply?: (activeCommentId: string, reply: IComment) => void;
54
55
  onComment?: () => void;
55
56
  setCommentDrawerOpen?: React.Dispatch<React.SetStateAction<boolean>>;
@@ -78,6 +79,7 @@ export interface CommentProviderProps extends CommentAccountProps {
78
79
  setUsername?: React.Dispatch<SetStateAction<string>>;
79
80
  activeCommentId: string | null;
80
81
  setActiveCommentId: React.Dispatch<React.SetStateAction<string | null>>;
82
+ activeTabId: string;
81
83
  focusCommentWithActiveId: (id: string) => void;
82
84
  ensResolutionUrl: string;
83
85
  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,61 @@
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, activeDragId, 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
+ activeDragId: string | null;
51
+ commentCount: number;
52
+ moveTabUp: () => void;
53
+ moveTabDown: () => void;
54
+ isPreviewMode: boolean;
55
+ isVersionHistoryMode?: boolean;
56
+ tabConfig?: DocumentOutlineProps["tabConfig"];
57
+ onDelete?: (tab: Tab) => void;
58
+ showOutline: boolean;
59
+ onShowOutlineChange: (value: boolean) => void;
60
+ isConnected?: boolean;
61
+ }) => 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;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare const MemorizedToC: React.MemoExoticComponent<React.MemoExoticComponent<({ items, editor, setItems, orientation }: import('./types').ToCProps) => 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: React.Dispatch<SetStateAction<boolean>> | undefined;
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
  }
@@ -47,6 +47,7 @@ export interface CommentStorage {
47
47
  }
48
48
  export interface IComment {
49
49
  id?: string;
50
+ tabId?: string;
50
51
  username?: string;
51
52
  reactions?: {
52
53
  count: number;
@@ -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,61 @@
1
+ import { Dispatch, 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
+ }
49
+ 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, }: UseTabEditorArgs) => {
50
+ editor: Editor | null;
51
+ ref: import('react').RefObject<HTMLDivElement>;
52
+ slides: string[];
53
+ setSlides: Dispatch<SetStateAction<string[]>>;
54
+ tocItems: ToCItemType[];
55
+ setTocItems: Dispatch<SetStateAction<ToCItemType[]>>;
56
+ activeCommentId: string | null;
57
+ setActiveCommentId: Dispatch<SetStateAction<string | null>>;
58
+ focusCommentWithActiveId: (id: string) => void;
59
+ isContentLoading: boolean | undefined;
60
+ };
61
+ export {};
@@ -0,0 +1,29 @@
1
+ import { DdocProps } from '../types';
2
+ import { Tab } from '../components/tabs/utils/tab-utils';
3
+ import * as Y from 'yjs';
4
+ interface UseTabManagerArgs {
5
+ ydoc: Y.Doc;
6
+ initialContent: DdocProps['initialContent'];
7
+ enableCollaboration: DdocProps['enableCollaboration'];
8
+ isDDocOwner: boolean;
9
+ createDefaultTabIfMissing: boolean;
10
+ shouldSyncActiveTab: boolean;
11
+ defaultTabId?: string;
12
+ }
13
+ export declare const getNewTabId: () => string;
14
+ export declare const useTabManager: ({ ydoc, initialContent, enableCollaboration, isDDocOwner, createDefaultTabIfMissing, shouldSyncActiveTab, defaultTabId, }: UseTabManagerArgs) => {
15
+ tabs: Tab[];
16
+ hasTabState: boolean;
17
+ activeTabId: string;
18
+ setTabs: import('react').Dispatch<import('react').SetStateAction<Tab[]>>;
19
+ setActiveTabId: (id: string) => void;
20
+ createTab: () => string;
21
+ deleteTab: (tabId: string) => void;
22
+ renameTab: (tabId: string, { newName, emoji }: {
23
+ newName?: string;
24
+ emoji?: string;
25
+ }) => void;
26
+ duplicateTab: (tabId: string) => string | undefined;
27
+ orderTab: (destinationTabId: string, movedTabId: string) => void;
28
+ };
29
+ 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 {};
@@ -71,6 +71,16 @@ export interface DocumentStyling {
71
71
  orientation?: 'portrait' | 'landscape';
72
72
  }
73
73
  export interface DdocProps extends CommentAccountProps {
74
+ tabConfig?: {
75
+ onCopyTabLink?: (tabId: string) => void;
76
+ defaultTabId?: string;
77
+ };
78
+ versionHistoryState?: {
79
+ enabled: boolean;
80
+ versionId: string;
81
+ content: string | string[];
82
+ };
83
+ tabSectionContainer?: HTMLElement;
74
84
  isCollabDocumentPublished?: boolean;
75
85
  ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
76
86
  url: string;
@@ -1,20 +1,36 @@
1
1
  import { DdocProps } from './types';
2
- import { ToCItemType } from './components/toc/types';
3
2
 
4
- import * as Y from 'yjs';
5
- export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, collabConfig, onIndexedDbError, disableInlineComment, ...rest }: Partial<DdocProps>) => {
6
- editor: import('@tiptap/core').Editor | null;
3
+ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHistoryState, enableCollaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, collabConfig, onIndexedDbError, disableInlineComment, ...rest }: Partial<DdocProps>) => {
4
+ ydoc: import('yjs').Doc;
5
+ awareness: any;
6
+ refreshYjsIndexedDbProvider: () => Promise<void>;
7
+ terminateSession: () => void;
7
8
  isContentLoading: boolean;
9
+ tabs: import('./components/tabs/utils/tab-utils').Tab[];
10
+ hasTabState: boolean;
11
+ isVersionMode: boolean;
12
+ activeTabId: string;
13
+ setTabs: import('react').Dispatch<import('react').SetStateAction<import('./components/tabs/utils/tab-utils').Tab[]>>;
14
+ setActiveTabId: (id: string) => void;
15
+ createTab: () => string;
16
+ deleteTab: (tabId: string) => void;
17
+ renameTab: (tabId: string, { newName, emoji }: {
18
+ newName?: string;
19
+ emoji?: string;
20
+ }) => void;
21
+ duplicateTab: (tabId: string) => string | undefined;
22
+ orderTab: (destinationTabId: string, movedTabId: string) => void;
23
+ onConnect: (connectConfig: import('./sync-local/useSyncMachine').IConnectConf) => void;
24
+ isReady: boolean;
25
+ hasCollabContentInitialised: boolean;
26
+ initialiseYjsIndexedDbProvider: () => Promise<void>;
27
+ editor: import('@tiptap/core').Editor | null;
8
28
  ref: import('react').RefObject<HTMLDivElement>;
9
- ydoc: Y.Doc;
10
- refreshYjsIndexedDbProvider: () => Promise<void>;
29
+ slides: string[];
30
+ setSlides: import('react').Dispatch<import('react').SetStateAction<string[]>>;
31
+ tocItems: import('./components/toc/types').ToCItemType[];
32
+ setTocItems: import('react').Dispatch<import('react').SetStateAction<import('./components/toc/types').ToCItemType[]>>;
11
33
  activeCommentId: string | null;
12
34
  setActiveCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
13
35
  focusCommentWithActiveId: (id: string) => void;
14
- slides: string[];
15
- setSlides: import('react').Dispatch<import('react').SetStateAction<string[]>>;
16
- tocItems: ToCItemType[];
17
- setTocItems: import('react').Dispatch<import('react').SetStateAction<ToCItemType[]>>;
18
- terminateSession: () => void;
19
- awareness: any;
20
36
  };