@fileverse-dev/ddoc 3.0.97 → 3.0.98-odfkit-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.
@@ -4,7 +4,7 @@ import { IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
4
4
  import { Tab } from './tabs/utils/tab-utils';
5
5
 
6
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, toggleFocusMode, }: {
7
+ declare const TiptapToolBar: ({ editor, onError, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, isLoading, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, }: {
8
8
  editor: Editor | null;
9
9
  onError?: (errorString: string) => void;
10
10
  zoomLevel: string;
@@ -17,6 +17,7 @@ declare const TiptapToolBar: ({ editor, onError, zoomLevel, setZoomLevel, isNavb
17
17
  onPdfExport?: () => void;
18
18
  onHtmlExport?: () => void;
19
19
  onTxtExport?: () => void;
20
+ onOdtExport?: () => void;
20
21
  onDocxImport?: () => void;
21
22
  isLoading: boolean;
22
23
  fetchV1ImageFn?: (url: string) => Promise<ArrayBuffer | undefined>;
@@ -56,7 +56,7 @@ export declare const IMG_UPLOAD_SETTINGS: {
56
56
  errorMsg: string;
57
57
  };
58
58
  };
59
- export declare const useEditorToolbar: ({ editor, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, }: {
59
+ export declare const useEditorToolbar: ({ editor, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, }: {
60
60
  editor: Editor | null;
61
61
  onError?: (errorString: string) => void;
62
62
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
@@ -65,6 +65,7 @@ export declare const useEditorToolbar: ({ editor, onError, ipfsImageUploadFn, on
65
65
  onPdfExport?: () => void;
66
66
  onHtmlExport?: () => void;
67
67
  onTxtExport?: () => void;
68
+ onOdtExport?: () => void;
68
69
  ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
69
70
  url: string;
70
71
  file: File;
@@ -15,10 +15,11 @@ interface PreviewModeExportTriggerProps {
15
15
  onPdfExport?: DdocProps['onPdfExport'];
16
16
  onHtmlExport?: DdocProps['onHtmlExport'];
17
17
  onTxtExport?: DdocProps['onTxtExport'];
18
+ onOdtExport?: DdocProps['onOdtExport'];
18
19
  ipfsImageFetchFn?: DdocProps['ipfsImageFetchFn'];
19
20
  onDocxImport?: DdocProps['onDocxImport'];
20
21
  fetchV1ImageFn?: DdocProps['fetchV1ImageFn'];
21
22
  isConnected?: DdocProps['isConnected'];
22
23
  }
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
+ declare const PreviewModeExportTrigger: ({ editor, ydoc, tabs, onRegisterExportTrigger, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, isConnected, }: PreviewModeExportTriggerProps) => import("react/jsx-runtime").JSX.Element;
24
25
  export { PreviewModeExportTrigger };
@@ -0,0 +1,27 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { IpfsImageFetchPayload } from '../../types';
3
+
4
+ declare module '@tiptap/core' {
5
+ interface Commands {
6
+ exportOdtFile: {
7
+ exportOdtFile: (props?: {
8
+ title?: string;
9
+ }) => any;
10
+ };
11
+ }
12
+ }
13
+ /**
14
+ * Preprocess TipTap HTML for odf-kit compatibility:
15
+ * - Convert task lists to standard lists with checkbox text prefixes
16
+ * - Remove <img> tags (odf-kit v1 skips images)
17
+ * - Strip TipTap-specific data attributes
18
+ * - Convert void elements to self-closing XHTML for the XML parser
19
+ */
20
+ export declare function preprocessHtml(html: string): {
21
+ html: string;
22
+ };
23
+ declare const OdtExportExtension: (ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
24
+ url: string;
25
+ file: File;
26
+ }>, fetchV1ImageFn?: (url: string) => Promise<ArrayBuffer | undefined>) => Extension<any, any>;
27
+ export default OdtExportExtension;
@@ -10,7 +10,7 @@ interface UseDdocExportArgs {
10
10
  exportOptions: (IEditorToolElement | null)[];
11
11
  }
12
12
  declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExportArgs) => {
13
- getOptionFormat: (title: string) => "" | "md" | "pdf" | "html" | "txt";
13
+ getOptionFormat: (title: string) => "" | "md" | "pdf" | "html" | "txt" | "odt";
14
14
  formatSelectOptions: {
15
15
  id: string;
16
16
  label: string;
@@ -3,7 +3,7 @@ import { DdocExportModalProps } from '../components/export-modal';
3
3
  import { UseHeadlessEditorProps } from './use-headless-editor';
4
4
 
5
5
  import * as Y from 'yjs';
6
- export type HeadlessEditorExportFormat = 'pdf' | 'md' | 'html' | 'txt';
6
+ export type HeadlessEditorExportFormat = 'pdf' | 'md' | 'html' | 'txt' | 'odt';
7
7
  export interface HeadlessEditorExportOption {
8
8
  content: string;
9
9
  fileName?: string;
@@ -48,7 +48,7 @@ interface UseTabEditorArgs {
48
48
  theme?: 'dark' | 'light';
49
49
  editorRef?: MutableRefObject<Editor | null>;
50
50
  }
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, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, theme, editorRef, }: UseTabEditorArgs) => {
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) => {
52
52
  editor: Editor | null;
53
53
  ref: import('react').RefObject<HTMLDivElement>;
54
54
  slides: string[];
@@ -14,6 +14,9 @@ export declare class SyncManager {
14
14
  private uncommittedUpdatesIdList;
15
15
  private contentTobeAppliedQueue;
16
16
  private isProcessing;
17
+ private flushTimer;
18
+ private readonly FLUSH_INTERVAL_MS;
19
+ private readonly MAX_QUEUE_SIZE;
17
20
  private _awarenessUpdateHandler;
18
21
  private ydoc;
19
22
  private servicesRef;
@@ -34,6 +37,15 @@ export declare class SyncManager {
34
37
  disconnect(): Promise<void>;
35
38
  terminateSession(): Promise<void>;
36
39
  enqueueLocalUpdate(update: Uint8Array): void;
40
+ private flushUpdates;
41
+ private awaitFlush;
42
+ /**
43
+ * Fire-and-forget: merge all queued updates, encrypt, and emit via Socket.IO
44
+ * without awaiting the server ACK. The server broadcasts to peers immediately
45
+ * (before MongoDB write), so content reaches observers in near-real-time.
46
+ * ACK callback handles updateId tracking and auto-commit asynchronously.
47
+ */
48
+ private sendUpdateBatch;
37
49
  forceCleanup(): void;
38
50
  private handleConnectionError;
39
51
  private handleReconnection;
@@ -109,6 +109,10 @@ export interface SyncManagerConfig {
109
109
  services?: CollabServices;
110
110
  callbacks?: CollabCallbacks;
111
111
  onLocalUpdate?: (updatedDocContent: Data['editorJSONData'], updateChunk: string) => void;
112
+ /** Origins to ignore in the ydoc update handler (e.g. IndexedDB provider) */
113
+ ignoredOrigins?: Array<{
114
+ current: unknown;
115
+ }>;
112
116
  }
113
117
  export declare enum ServerErrorCode {
114
118
  AUTH_TOKEN_MISSING = "AUTH_TOKEN_MISSING",
@@ -165,6 +165,7 @@ export interface DdocProps extends CommentAccountProps {
165
165
  onPdfExport?: () => void;
166
166
  onHtmlExport?: () => void;
167
167
  onTxtExport?: () => void;
168
+ onOdtExport?: () => void;
168
169
  onDocxImport?: () => void;
169
170
  sharedSlidesLink?: string;
170
171
  documentName?: string;