@fileverse-dev/ddoc 3.5.1 → 3.5.2-font-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/dist/index.d.ts +1 -0
- package/dist/index.es.js +22348 -21651
- package/dist/package/components/editor-toolbar.d.ts +3 -2
- package/dist/package/components/editor-utils.d.ts +9 -4
- package/dist/package/types.d.ts +25 -0
- package/dist/package/use-ddoc-editor.d.ts +1 -1
- package/dist/package/utils/font-loader.d.ts +7 -0
- package/dist/style.css +1 -1
- package/package.json +2 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Editor } from '@tiptap/react';
|
|
3
|
-
import { IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
|
|
3
|
+
import { FontDescriptor, 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 MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, isLoading, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, }: {
|
|
7
|
+
declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, isLoading, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, fonts: consumerFonts, }: {
|
|
8
8
|
editor: Editor | null;
|
|
9
9
|
onError?: (errorString: string) => void;
|
|
10
10
|
isPresentationMode?: boolean;
|
|
@@ -33,5 +33,6 @@ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onErro
|
|
|
33
33
|
ydoc: Y.Doc;
|
|
34
34
|
toggleFocusMode?: () => void;
|
|
35
35
|
onRegisterExportTrigger?: ((trigger: ((format?: string, name?: string) => void) | null) => void) | undefined;
|
|
36
|
+
fonts?: FontDescriptor[];
|
|
36
37
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
37
38
|
export default MemoizedTiptapToolBar;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { FontDescriptor, IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
|
|
2
3
|
import { IEditorTool } from '../hooks/use-visibility';
|
|
3
4
|
import { Editor } from '@tiptap/react';
|
|
4
|
-
import { IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
|
|
5
5
|
|
|
6
6
|
export interface IEditorToolElement {
|
|
7
7
|
icon: any;
|
|
@@ -14,11 +14,14 @@ export interface IEditorToolElement {
|
|
|
14
14
|
notVisible?: number;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
type PickerEntry = {
|
|
18
18
|
title: string;
|
|
19
19
|
value: string;
|
|
20
20
|
command: (editor: Editor) => void;
|
|
21
|
-
|
|
21
|
+
preview?: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
export declare const baselineFonts: PickerEntry[];
|
|
24
|
+
export declare function buildPickerEntries(consumerFonts: FontDescriptor[]): PickerEntry[];
|
|
22
25
|
export declare const FONT_SIZES: readonly [8, 9, 10, 11, 12, 14, 16, 18, 24, 30, 32, 36, 48, 60, 72, 96];
|
|
23
26
|
export declare const getFontSizeOptions: (editor?: Editor) => {
|
|
24
27
|
title: string;
|
|
@@ -96,10 +99,11 @@ export declare const TextHighlighter: ({ editor, setVisibility, elementRef, }: {
|
|
|
96
99
|
elementRef: React.RefObject<HTMLDivElement>;
|
|
97
100
|
setVisibility: Dispatch<SetStateAction<IEditorTool>>;
|
|
98
101
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
99
|
-
export declare const EditorFontFamily: ({ elementRef, editor, setToolVisibility, }: {
|
|
102
|
+
export declare const EditorFontFamily: ({ elementRef, editor, setToolVisibility, fonts: consumerFonts, }: {
|
|
100
103
|
elementRef: React.RefObject<HTMLDivElement>;
|
|
101
104
|
editor: Editor;
|
|
102
105
|
setToolVisibility: Dispatch<SetStateAction<IEditorTool>>;
|
|
106
|
+
fonts?: FontDescriptor[];
|
|
103
107
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
104
108
|
export declare const EditorAlignment: ({ elementRef, editor, setToolVisibility, }: {
|
|
105
109
|
elementRef: React.RefObject<HTMLDivElement>;
|
|
@@ -182,3 +186,4 @@ export declare const checkActiveListsAndDBlocks: (editor: Editor) => {
|
|
|
182
186
|
state: import('prosemirror-state').EditorState;
|
|
183
187
|
hasMultipleLists: boolean;
|
|
184
188
|
};
|
|
189
|
+
export {};
|
package/dist/package/types.d.ts
CHANGED
|
@@ -105,6 +105,13 @@ export interface DocumentStyling {
|
|
|
105
105
|
orientation?: 'portrait' | 'landscape';
|
|
106
106
|
}
|
|
107
107
|
export interface DdocProps extends CommentAccountProps {
|
|
108
|
+
/**
|
|
109
|
+
* Optional catalog of fonts available to the editor in addition to the
|
|
110
|
+
* package baseline (system fonts only). Each entry is loaded lazily via the
|
|
111
|
+
* CSS Font Loading API when first selected in the picker or when a document
|
|
112
|
+
* references its family.
|
|
113
|
+
*/
|
|
114
|
+
fonts?: FontDescriptor[];
|
|
108
115
|
tabConfig?: {
|
|
109
116
|
onCopyTabLink?: (tabId: string) => void;
|
|
110
117
|
defaultTabId?: string;
|
|
@@ -247,3 +254,21 @@ export interface IpfsImageFetchPayload {
|
|
|
247
254
|
mimeType: string;
|
|
248
255
|
authTag: string;
|
|
249
256
|
}
|
|
257
|
+
export type FontDescriptor = {
|
|
258
|
+
/** Display name in the picker, e.g. "Poppins" */
|
|
259
|
+
name: string;
|
|
260
|
+
/** CSS font-family stack stored in textStyle marks, e.g. "Poppins, sans-serif" */
|
|
261
|
+
family: string;
|
|
262
|
+
/**
|
|
263
|
+
* woff2 source(s).
|
|
264
|
+
* - string: single file covering all weights (variable font).
|
|
265
|
+
* - Record<number, string>: per-weight map, e.g. { 400: '/p-400.woff2', 700: '/p-700.woff2' }.
|
|
266
|
+
* - omitted: pure system font, no loading.
|
|
267
|
+
*/
|
|
268
|
+
url?: string | Record<number, string>;
|
|
269
|
+
/**
|
|
270
|
+
* SVG preview rendered in the picker. Any React node that renders an <svg>.
|
|
271
|
+
* Falls back to the font name in the default font when absent.
|
|
272
|
+
*/
|
|
273
|
+
preview?: React.ReactNode;
|
|
274
|
+
};
|
|
@@ -2,7 +2,7 @@ import { DdocProps } from './types';
|
|
|
2
2
|
import { Editor } from '@tiptap/react';
|
|
3
3
|
import { DBlockRuntimeState } from './extensions/d-block/dblock-runtime';
|
|
4
4
|
|
|
5
|
-
export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent, versionHistoryState, collaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setPageCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, isPreviewEditor, ...rest }: Partial<DdocProps> & {
|
|
5
|
+
export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent, versionHistoryState, collaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setPageCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, isPreviewEditor, fonts, ...rest }: Partial<DdocProps> & {
|
|
6
6
|
isFocusMode?: boolean;
|
|
7
7
|
isPreviewEditor?: boolean;
|
|
8
8
|
}) => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FontDescriptor } from '../types';
|
|
2
|
+
|
|
3
|
+
/** "Poppins, sans-serif" -> "Poppins"; "'Times New Roman', serif" -> "Times New Roman" */
|
|
4
|
+
export declare function primaryToken(family: string): string;
|
|
5
|
+
export declare function registerFonts(fonts: FontDescriptor[]): void;
|
|
6
|
+
export declare function isLoaded(family: string): boolean;
|
|
7
|
+
export declare function ensureLoaded(family: string): Promise<void>;
|