@fileverse-dev/ddoc 3.0.64 → 3.0.65-export-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.
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +12969 -12655
- package/dist/package/components/export-modal.d.ts +4 -5
- package/dist/package/extensions/font-family-persistence.d.ts +11 -0
- package/dist/package/extensions/typography-persistence.d.ts +22 -0
- package/dist/package/hooks/use-ddoc-export.d.ts +6 -1
- package/dist/package/hooks/use-export-headless-editor-content.d.ts +31 -0
- package/dist/package/hooks/use-headless-editor.d.ts +3 -2
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
interface ExportFormatOption {
|
|
1
|
+
export interface ExportFormatOption {
|
|
2
2
|
id: string;
|
|
3
3
|
label: string;
|
|
4
4
|
}
|
|
5
|
-
interface ExportTabOption {
|
|
5
|
+
export interface ExportTabOption {
|
|
6
6
|
id: string;
|
|
7
7
|
label: string;
|
|
8
8
|
}
|
|
9
|
-
interface
|
|
9
|
+
export interface DdocExportModalProps {
|
|
10
10
|
open: boolean;
|
|
11
11
|
onOpenChange: (open: boolean) => void;
|
|
12
12
|
onExport?: (data: {
|
|
@@ -18,5 +18,4 @@ interface ExportAsModalProps {
|
|
|
18
18
|
initialFormat?: string;
|
|
19
19
|
initialTab?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare const
|
|
22
|
-
export {};
|
|
21
|
+
export declare const DdocExportModal: ({ open, onOpenChange, onExport, formatOptions, tabOptions, initialFormat, initialTab, }: DdocExportModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
declare module '@tiptap/core' {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
fontFamilyPersistence: {
|
|
6
|
+
setFontFamily: (fontFamily: string) => ReturnType;
|
|
7
|
+
unsetFontFamily: () => ReturnType;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const FontFamilyPersistence: Extension<any, any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypographyPersistence consolidates fontFamily and fontSize persistence logic
|
|
5
|
+
* into a single extension with 3 plugins, replacing the 6 individual plugins
|
|
6
|
+
* that were split across FontFamilyPersistence and FontSize.
|
|
7
|
+
*
|
|
8
|
+
* Plugins:
|
|
9
|
+
* 1. typographyInheritance — when a new paragraph is inserted next to a styled
|
|
10
|
+
* one, inherit fontFamily and fontSize in a single setNodeMarkup pass.
|
|
11
|
+
* Skips trailing-node paragraphs (they inherit from the previous sibling
|
|
12
|
+
* at creation time, but should not be overridden when the user clears them).
|
|
13
|
+
* 2. typographyStoredMarks — when selection moves into an empty styled
|
|
14
|
+
* paragraph, restore storedMarks for both fontFamily and fontSize at once.
|
|
15
|
+
* 3. typographySyncNodeAttr — when storedMarks change on an empty paragraph,
|
|
16
|
+
* update both node attributes in one setNodeMarkup call.
|
|
17
|
+
* Clearing only happens when the textStyle mark itself explicitly has a null
|
|
18
|
+
* value for the property — NOT when non-textStyle marks (bold, italic, etc.)
|
|
19
|
+
* are stored, which was previously causing font attrs to be wiped on
|
|
20
|
+
* bold/italic toggle.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TypographyPersistence: Extension<any, any>;
|
|
@@ -6,7 +6,7 @@ import * as Y from 'yjs';
|
|
|
6
6
|
interface UseDdocExportArgs {
|
|
7
7
|
editor: Editor | null;
|
|
8
8
|
tabs: Tab[];
|
|
9
|
-
ydoc: Y.Doc;
|
|
9
|
+
ydoc: Y.Doc | null;
|
|
10
10
|
exportOptions: (IEditorToolElement | null)[];
|
|
11
11
|
}
|
|
12
12
|
declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExportArgs) => {
|
|
@@ -20,5 +20,10 @@ declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExp
|
|
|
20
20
|
tab: string;
|
|
21
21
|
name?: string;
|
|
22
22
|
}) => void;
|
|
23
|
+
handleExportAsync: ({ format, tab, name, }: {
|
|
24
|
+
format: string;
|
|
25
|
+
tab: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}) => Promise<void>;
|
|
23
28
|
};
|
|
24
29
|
export { useDdocExport };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor, JSONContent } from '@tiptap/react';
|
|
2
|
+
import { DdocExportModalProps } from '../components/export-modal';
|
|
3
|
+
import { UseHeadlessEditorProps } from './use-headless-editor';
|
|
4
|
+
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
export type HeadlessEditorExportFormat = 'pdf' | 'md' | 'html' | 'txt';
|
|
7
|
+
export interface HeadlessEditorExportOption {
|
|
8
|
+
content: string;
|
|
9
|
+
fileName?: string;
|
|
10
|
+
initialFormat?: HeadlessEditorExportFormat;
|
|
11
|
+
}
|
|
12
|
+
export declare const useExportHeadlessEditorContent: (props?: UseHeadlessEditorProps) => {
|
|
13
|
+
exportContent: (option: HeadlessEditorExportOption) => void;
|
|
14
|
+
exportModalProps: DdocExportModalProps;
|
|
15
|
+
setContent: (initialContent: string | string[] | JSONContent, editor: Editor, ydoc: Y.Doc) => void;
|
|
16
|
+
getEditor: () => {
|
|
17
|
+
editor: Editor;
|
|
18
|
+
ydoc: Y.Doc;
|
|
19
|
+
};
|
|
20
|
+
getYjsConvertor: () => {
|
|
21
|
+
convertJSONContentToYjsEncodedString: (content: JSONContent) => string;
|
|
22
|
+
cleanup: () => void;
|
|
23
|
+
};
|
|
24
|
+
downloadContentAsMd: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
25
|
+
downloadContentAsHtml: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
26
|
+
downloadContentAsTxt: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
27
|
+
mergeYjsUpdates: (contents: string[]) => string;
|
|
28
|
+
handleMarkdownContent: typeof import('../extensions/mardown-paste-handler').handleMarkdownContent;
|
|
29
|
+
getYjsContentFromMarkdown: (file: File, ipfsImageUploadFn: (file: File) => Promise<import('../types').IpfsImageUploadResponse>) => Promise<string | null>;
|
|
30
|
+
getYjsContentFromDocx: (file: File, ipfsImageUploadFn: (file: File) => Promise<import('../types').IpfsImageUploadResponse>) => Promise<string | null>;
|
|
31
|
+
};
|
|
@@ -3,9 +3,10 @@ import { handleMarkdownContent } from '../extensions/mardown-paste-handler';
|
|
|
3
3
|
import { IpfsImageUploadResponse } from '../types';
|
|
4
4
|
|
|
5
5
|
import * as Y from 'yjs';
|
|
6
|
-
export
|
|
6
|
+
export interface UseHeadlessEditorProps {
|
|
7
7
|
optionalExtensions?: string[];
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
export declare const useHeadlessEditor: (props?: UseHeadlessEditorProps) => {
|
|
9
10
|
setContent: (initialContent: string | string[] | JSONContent, editor: Editor, ydoc: Y.Doc) => void;
|
|
10
11
|
getEditor: () => {
|
|
11
12
|
editor: Editor;
|