@fileverse-dev/ddoc 7.2.3 → 7.2.4

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.
@@ -1,10 +1,11 @@
1
1
  import { default as React } from 'react';
2
2
  import { Editor } from '@tiptap/react';
3
3
  import { FontDescriptor, IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
4
+ import { ExportErrorHandler } from '../utils/export-watchdog';
4
5
  import { Tab } from './tabs/utils/tab-utils';
5
6
 
6
7
  import * as Y from 'yjs';
7
- declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, isNavbarVisible, setIsNavbarVisible, showNavbarToggle, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, isSplitView, onToggleSplitView, fonts: consumerFonts, renderToolbarLeading, }: {
8
+ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, isNavbarVisible, setIsNavbarVisible, showNavbarToggle, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onExportError, onDocxImport, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, isSplitView, onToggleSplitView, fonts: consumerFonts, renderToolbarLeading, }: {
8
9
  editor: Editor | null;
9
10
  onError?: (errorString: string) => void;
10
11
  isPresentationMode?: boolean;
@@ -20,6 +21,7 @@ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onErro
20
21
  onHtmlExport?: () => void;
21
22
  onTxtExport?: () => void;
22
23
  onOdtExport?: () => void;
24
+ onExportError?: ExportErrorHandler;
23
25
  onDocxImport?: () => void;
24
26
  fetchV1ImageFn?: (url: string) => Promise<ArrayBuffer | undefined>;
25
27
  ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
@@ -3,11 +3,12 @@ import { FontDescriptor, IpfsImageFetchPayload, IpfsImageUploadResponse } from '
3
3
  import { IEditorTool } from '../hooks/use-visibility';
4
4
  import { Editor } from '@tiptap/react';
5
5
  import { EditorProps } from '@tiptap/pm/view';
6
+ import { ExportErrorHandler } from '../utils/export-watchdog';
6
7
 
7
8
  export interface IEditorToolElement {
8
9
  icon: any;
9
10
  title: string;
10
- onClick: (name?: string) => void;
11
+ onClick: (name?: string) => void | Promise<void>;
11
12
  isActive: boolean;
12
13
  group?: string;
13
14
  isNew?: boolean;
@@ -52,7 +53,7 @@ export declare function shortcutAction(event: Pick<KeyboardEvent, 'key' | 'metaK
52
53
  * `editor.setOptions({ editorProps: ... })` directly.
53
54
  */
54
55
  export declare const mergeEditorProps: (editor: Editor, patch: Partial<EditorProps>) => void;
55
- export declare const useEditorToolbar: ({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, }: {
56
+ export declare const useEditorToolbar: ({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onExportError, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, }: {
56
57
  editor: Editor | null;
57
58
  isPresentationMode?: boolean;
58
59
  setIsPresentationMode?: () => void;
@@ -65,6 +66,7 @@ export declare const useEditorToolbar: ({ editor, onError, isPresentationMode, s
65
66
  onHtmlExport?: () => void;
66
67
  onTxtExport?: () => void;
67
68
  onOdtExport?: () => void;
69
+ onExportError?: ExportErrorHandler;
68
70
  ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
69
71
  url: string;
70
72
  file: File;
@@ -1,9 +1,10 @@
1
1
  import { CopyAo3Html, IEditorToolElement } from './editor-utils';
2
2
  import { Editor } from '@tiptap/react';
3
3
  import { Tab } from './tabs/utils/tab-utils';
4
+ import { ExportErrorHandler } from '../utils/export-watchdog';
4
5
 
5
6
  import * as Y from 'yjs';
6
- declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, editor, tabs, ydoc, copyAo3Html, onRegisterExportTrigger, }: {
7
+ declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, exportOptions, importOptions, editor, tabs, ydoc, copyAo3Html, onRegisterExportTrigger, onExportError, }: {
7
8
  fileExportsOpen: boolean;
8
9
  setFileExportsOpen: React.Dispatch<React.SetStateAction<boolean>>;
9
10
  exportOptions: (IEditorToolElement | null)[];
@@ -13,5 +14,6 @@ declare const ImportExportButton: ({ fileExportsOpen, setFileExportsOpen, export
13
14
  ydoc: Y.Doc;
14
15
  copyAo3Html: CopyAo3Html;
15
16
  onRegisterExportTrigger?: ((trigger: ((format?: string, name?: string) => void) | null) => void) | undefined;
17
+ onExportError?: ExportErrorHandler;
16
18
  }) => import("react/jsx-runtime").JSX.Element;
17
19
  export { ImportExportButton };
@@ -16,10 +16,11 @@ interface PreviewModeExportTriggerProps {
16
16
  onHtmlExport?: DdocProps['onHtmlExport'];
17
17
  onTxtExport?: DdocProps['onTxtExport'];
18
18
  onOdtExport?: DdocProps['onOdtExport'];
19
+ onExportError?: DdocProps['onExportError'];
19
20
  ipfsImageFetchFn?: DdocProps['ipfsImageFetchFn'];
20
21
  onDocxImport?: DdocProps['onDocxImport'];
21
22
  fetchV1ImageFn?: DdocProps['fetchV1ImageFn'];
22
23
  isConnected?: DdocProps['isConnected'];
23
24
  }
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;
25
+ declare const PreviewModeExportTrigger: ({ editor, ydoc, tabs, onRegisterExportTrigger, onError, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onExportError, ipfsImageFetchFn, onDocxImport, fetchV1ImageFn, isConnected, }: PreviewModeExportTriggerProps) => import("react/jsx-runtime").JSX.Element;
25
26
  export { PreviewModeExportTrigger };
@@ -1,6 +1,7 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import { CopyAo3Html, IEditorToolElement } from '../components/editor-utils';
3
3
  import { Tab } from '../components/tabs/utils/tab-utils';
4
+ import { ExportErrorHandler } from '../utils/export-watchdog';
4
5
 
5
6
  import * as Y from 'yjs';
6
7
  interface UseDdocExportArgs {
@@ -9,8 +10,9 @@ interface UseDdocExportArgs {
9
10
  ydoc: Y.Doc | null;
10
11
  exportOptions: (IEditorToolElement | null)[];
11
12
  copyAo3Html?: CopyAo3Html;
13
+ onExportError?: ExportErrorHandler;
12
14
  }
13
- declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, copyAo3Html, }: UseDdocExportArgs) => {
15
+ declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, copyAo3Html, onExportError, }: UseDdocExportArgs) => {
14
16
  getOptionFormat: (title: string) => "" | "md" | "html" | "pdf" | "ao3-html" | "md-css" | "txt" | "odt";
15
17
  formatSelectOptions: {
16
18
  id: string;
@@ -137,6 +137,11 @@ export type PageSetup = {
137
137
  mode: 'pages' | 'pageless';
138
138
  paper: 'a4' | 'letter';
139
139
  };
140
+ export type ExportErrorContext = {
141
+ format: string;
142
+ /** Last step reached before the failure, e.g. `embed-images`, `print`, `timeout`. */
143
+ stage: string;
144
+ };
140
145
  export type DdocStats = {
141
146
  words: number;
142
147
  characters: number;
@@ -332,6 +337,7 @@ export interface DdocProps extends CommentAccountProps {
332
337
  onHtmlExport?: () => void;
333
338
  onTxtExport?: () => void;
334
339
  onOdtExport?: () => void;
340
+ onExportError?: (error: unknown, context: ExportErrorContext) => void;
335
341
  onDocxImport?: () => void;
336
342
  sharedSlidesLink?: string;
337
343
  documentName?: string;
@@ -0,0 +1,5 @@
1
+ import { ExportErrorContext } from '../types';
2
+
3
+ export type ExportErrorHandler = (error: unknown, context: ExportErrorContext) => void;
4
+ /** A catch cannot see an export that hangs, so report one still running after a minute. */
5
+ export declare const startExportWatchdog: (format: string, getStage: () => string, onExportError?: ExportErrorHandler) => (() => void);
@@ -15,5 +15,5 @@ export type ContentPrintOptions = {
15
15
  export declare const mountContentPrintHost: (content: string, options?: ContentPrintOptions) => {
16
16
  cleanup: () => void;
17
17
  };
18
- export declare const handleContentPrint: (content: string, options?: ContentPrintOptions) => void;
18
+ export declare const handleContentPrint: (content: string, options?: ContentPrintOptions) => Promise<void>;
19
19
  export {};