@fileverse-dev/ddoc 2.0.3-sync-patch-10 → 2.0.3-sync-patch-12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. package/README.md +22 -20
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.es.js +40369 -39423
  4. package/dist/package/components/editor-bubble-menu.d.ts +3 -1
  5. package/dist/package/components/editor-toolbar.d.ts +2 -1
  6. package/dist/package/components/editor-utils.d.ts +12 -2
  7. package/dist/package/components/mobile-toolbar.d.ts +2 -1
  8. package/dist/package/components/secure-image.d.ts +13 -0
  9. package/dist/package/components/slash-comand.d.ts +1 -1
  10. package/dist/package/components/tag-input.d.ts +12 -0
  11. package/dist/package/extensions/customTextInputRules.d.ts +4 -0
  12. package/dist/package/extensions/d-block/dblock-node-view.d.ts +3 -1
  13. package/dist/package/extensions/d-block/dblock.d.ts +1 -0
  14. package/dist/package/extensions/default-extension.d.ts +1 -1
  15. package/dist/package/extensions/page-break/index.d.ts +1 -0
  16. package/dist/package/extensions/page-break/page-break-node-view.d.ts +4 -0
  17. package/dist/package/extensions/page-break/page-break.d.ts +20 -0
  18. package/dist/package/extensions/resizable-media/media-paste-drop-plugin/media-paste-drop-plugin.d.ts +1 -1
  19. package/dist/package/extensions/resizable-media/resizable-media.d.ts +2 -0
  20. package/dist/package/preview-ddoc-editor.d.ts +4 -0
  21. package/dist/package/types.d.ts +11 -19
  22. package/dist/package/use-ddoc-editor.d.ts +4 -8
  23. package/dist/package/utils/security.d.ts +17 -0
  24. package/dist/package/utils/upload-images.d.ts +3 -1
  25. package/dist/style.css +1 -1
  26. package/package.json +5 -4
  27. package/dist/package/extensions/sync-cursor.d.ts +0 -12
@@ -6,6 +6,8 @@ export interface BubbleMenuItem {
6
6
  command: () => void;
7
7
  icon: any;
8
8
  }
9
- type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'>;
9
+ type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'> & {
10
+ onError?: (errorString: string) => void;
11
+ };
10
12
  export declare const EditorBubbleMenu: (props: EditorBubbleMenuProps) => import("react/jsx-runtime").JSX.Element;
11
13
  export {};
@@ -1,10 +1,11 @@
1
1
  import { default as React } from 'react';
2
2
  import { Editor } from '@tiptap/react';
3
3
 
4
- declare const TiptapToolBar: ({ editor, onError, isNavbarVisible, setIsNavbarVisible, }: {
4
+ declare const TiptapToolBar: ({ editor, onError, isNavbarVisible, setIsNavbarVisible, secureImageUploadUrl, }: {
5
5
  editor: Editor;
6
6
  onError?: (errorString: string) => void;
7
7
  isNavbarVisible: boolean;
8
8
  setIsNavbarVisible: React.Dispatch<React.SetStateAction<boolean>>;
9
+ secureImageUploadUrl?: string;
9
10
  }) => import("react/jsx-runtime").JSX.Element;
10
11
  export default TiptapToolBar;
@@ -13,13 +13,23 @@ export declare const fonts: {
13
13
  value: string;
14
14
  command: (editor: Editor) => void;
15
15
  }[];
16
- export declare const MAX_IMAGE_SIZE: number;
17
16
  export declare const ERR_MSG_MAP: {
18
17
  IMAGE_SIZE: string;
19
18
  };
20
- export declare const useEditorToolbar: ({ editor, onError, }: {
19
+ export declare const IMG_UPLOAD_SETTINGS: {
20
+ Extended: {
21
+ maxSize: number;
22
+ errorMsg: string;
23
+ };
24
+ Base: {
25
+ maxSize: number;
26
+ errorMsg: string;
27
+ };
28
+ };
29
+ export declare const useEditorToolbar: ({ editor, onError, secureImageUploadUrl, }: {
21
30
  editor: Editor;
22
31
  onError?: (errorString: string) => void;
32
+ secureImageUploadUrl?: string;
23
33
  }) => {
24
34
  undoRedoTools: (IEditorToolElement | null)[];
25
35
  toolbar: (IEditorToolElement | null)[];
@@ -1,10 +1,11 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
 
3
- declare const MobileToolbar: ({ editor, onError, isKeyboardVisible, isNavbarVisible, setIsNavbarVisible, }: {
3
+ declare const MobileToolbar: ({ editor, onError, isKeyboardVisible, isNavbarVisible, setIsNavbarVisible, secureImageUploadUrl, }: {
4
4
  editor: Editor;
5
5
  onError?: (errorString: string) => void;
6
6
  isKeyboardVisible: boolean;
7
7
  isNavbarVisible: boolean;
8
8
  setIsNavbarVisible: React.Dispatch<React.SetStateAction<boolean>>;
9
+ secureImageUploadUrl?: string;
9
10
  }) => import("react/jsx-runtime").JSX.Element;
10
11
  export default MobileToolbar;
@@ -0,0 +1,13 @@
1
+ type Props = {
2
+ encryptedKey: string;
3
+ url: string;
4
+ iv: string;
5
+ privateKey: string;
6
+ alt?: string;
7
+ width?: string;
8
+ height?: string;
9
+ className?: string;
10
+ caption?: string;
11
+ };
12
+ export declare const SecureImage: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLImageElement>>;
13
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { Extension } from '@tiptap/core';
2
2
 
3
3
  export declare const updateScrollView: (container: HTMLElement, item: HTMLElement) => void;
4
- declare const SlashCommand: (onError?: (errorString: string) => void) => Extension<any, any>;
4
+ declare const SlashCommand: (onError?: (errorString: string) => void, secureImageUploadUrl?: string) => Extension<any, any>;
5
5
  export default SlashCommand;
@@ -0,0 +1,12 @@
1
+ export interface TagProps {
2
+ name: string;
3
+ color: string;
4
+ }
5
+ export interface TagInputProps {
6
+ tags: TagProps[];
7
+ selectedTags: TagProps[];
8
+ onAddTag: (tag: TagProps) => void;
9
+ isPreviewMode: boolean;
10
+ }
11
+ declare const TagInput: ({ tags, selectedTags, onAddTag, isPreviewMode }: TagInputProps) => import("react/jsx-runtime").JSX.Element | null;
12
+ export { TagInput };
@@ -0,0 +1,4 @@
1
+ import { Extension } from '@tiptap/core';
2
+
3
+ declare const customTextInputRules: Extension<any, any>;
4
+ export default customTextInputRules;
@@ -1,4 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { NodeViewProps } from '@tiptap/react';
3
3
 
4
- export declare const DBlockNodeView: React.FC<NodeViewProps>;
4
+ export declare const DBlockNodeView: React.FC<NodeViewProps & {
5
+ secureImageUploadUrl?: string;
6
+ }>;
@@ -2,6 +2,7 @@ import { Node } from '@tiptap/core';
2
2
 
3
3
  export interface DBlockOptions {
4
4
  HTMLAttributes: Record<string, any>;
5
+ secureImageUploadUrl?: string;
5
6
  }
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,5 +1,5 @@
1
1
  import { NodeType } from '@tiptap/pm/model';
2
2
  import { InputRule } from '@tiptap/core';
3
3
 
4
- export declare const defaultExtensions: (import('@tiptap/core').Node<any, any> | import('@tiptap/core').Extension<any, any> | import('@tiptap/core').Mark<any, any>)[];
4
+ export declare const defaultExtensions: (onError: (error: string) => void, secureImageUploadUrl?: string) => (import('@tiptap/core').Node<any, any> | import('@tiptap/core').Extension<any, any> | import('@tiptap/core').Mark<any, any>)[];
5
5
  export declare const createInputRule: (pattern: RegExp, data: string, type: NodeType) => InputRule;
@@ -0,0 +1 @@
1
+ export * from './page-break';
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { NodeViewProps } from '@tiptap/react';
3
+
4
+ export declare const PageBreakNodeView: React.FC<NodeViewProps>;
@@ -0,0 +1,20 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ export interface PageBreakRuleOptions {
4
+ HTMLAttributes: Record<string, any>;
5
+ }
6
+ declare module '@tiptap/core' {
7
+ interface Commands<ReturnType> {
8
+ pageBreak: {
9
+ /**
10
+ * Add a page break
11
+ */
12
+ setPageBreak: () => ReturnType;
13
+ /**
14
+ * Remove a page break
15
+ */
16
+ unsetPageBreak: () => ReturnType;
17
+ };
18
+ }
19
+ }
20
+ export declare const PageBreak: Node<PageBreakRuleOptions, any>;
@@ -9,4 +9,4 @@ export type UploadFnType = (image: File) => Promise<string>;
9
9
  * If no upload function is provided, it reads the media file as DataURL and uses this in the new node.
10
10
  * The function returns a new instance of the Plugin.
11
11
  */
12
- export declare const getMediaPasteDropPlugin: (upload: UploadFnType) => Plugin<any>;
12
+ export declare const getMediaPasteDropPlugin: (upload: UploadFnType, onError: (error: string) => void, secureImageUploadUrl?: string) => Plugin<any>;
@@ -21,6 +21,8 @@ declare module '@tiptap/core' {
21
21
  export interface MediaOptions {
22
22
  HTMLAttributes: Record<string, any>;
23
23
  uploadFn: UploadFnType;
24
+ onError: (error: string) => void;
25
+ secureImageUploadUrl?: string;
24
26
  }
25
27
  export declare const IMAGE_INPUT_REGEX: RegExp;
26
28
  export declare const VIDEO_INPUT_REGEX: RegExp;
@@ -0,0 +1,4 @@
1
+ import { DdocProps } from './types';
2
+
3
+ declare const PreviewDdocEditor: import('react').ForwardRefExoticComponent<DdocProps & import('react').RefAttributes<unknown>>;
4
+ export { PreviewDdocEditor };
@@ -1,3 +1,4 @@
1
+ import { TagType } from '@fileverse/ui';
1
2
  import { JSONContent } from '@tiptap/core';
2
3
  import { EditorProps } from '@tiptap/pm/view';
3
4
  import { Editor } from '@tiptap/react';
@@ -10,17 +11,20 @@ export interface IDocCollabUsers {
10
11
  color: string;
11
12
  }
12
13
  export interface DdocProps {
14
+ selectedTags?: TagType[];
15
+ setSelectedTags?: React.Dispatch<SetStateAction<TagType[]>>;
13
16
  enableCollaboration?: boolean;
14
17
  collaborationId?: string;
15
18
  isPreviewMode: boolean;
16
19
  ensResolutionUrl?: string;
20
+ secureImageUploadUrl?: string;
17
21
  initialContent?: JSONContent | null;
18
22
  walletAddress?: string | null;
19
23
  username?: string | null;
20
24
  renderNavbar?: ({ editor }: {
21
25
  editor: JSONContent;
22
26
  }) => JSX.Element;
23
- onChange?: (changes: string) => void;
27
+ onChange?: (changes: Data['editorJSONData']) => void;
24
28
  onCollaboratorChange?: (collaborators: undefined | IDocCollabUsers[]) => void;
25
29
  onTextSelection?: (data: IEditorSelectionData) => void;
26
30
  onCommentInteraction?: (data: IEditorSelectionData) => void;
@@ -30,8 +34,12 @@ export interface DdocProps {
30
34
  onError?: (error: string) => void;
31
35
  setCharacterCount?: React.Dispatch<SetStateAction<number>>;
32
36
  setWordCount?: React.Dispatch<SetStateAction<number>>;
33
- collaborationKey?: string;
34
- yjsUpdate?: string;
37
+ tags?: Array<{
38
+ name: string;
39
+ color: string;
40
+ }>;
41
+ className?: string;
42
+ scrollPosition?: number;
35
43
  }
36
44
  export interface IEditorSelectionData {
37
45
  from: number;
@@ -47,19 +55,3 @@ export interface IUser {
47
55
  color: string;
48
56
  isEns: boolean;
49
57
  }
50
- export type CollaborationCursorStorage = {
51
- users: {
52
- clientId: number;
53
- [key: string]: any;
54
- }[];
55
- };
56
- export interface CollaborationCursorOptions {
57
- provider: any;
58
- user: Record<string, any>;
59
- render(user: Record<string, any>): HTMLElement;
60
- selectionRender(user: Record<string, any>): any;
61
- onUpdate: (users: {
62
- clientId: number;
63
- [key: string]: any;
64
- }[]) => null;
65
- }
@@ -1,14 +1,10 @@
1
1
  import { DdocProps } from './types';
2
2
 
3
- export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration, collaborationId, walletAddress, username, onChange, onCollaboratorChange, onCommentInteraction, onTextSelection, ensResolutionUrl, onError, setCharacterCount, setWordCount, collaborationKey, yjsUpdate, }: Partial<DdocProps>) => {
3
+ import * as Y from 'yjs';
4
+ export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration, collaborationId, walletAddress, username, onChange, onCollaboratorChange, onCommentInteraction, onTextSelection, ensResolutionUrl, onError, setCharacterCount, setWordCount, secureImageUploadUrl, scrollPosition, }: Partial<DdocProps>) => {
4
5
  editor: import('@tiptap/core').Editor | null;
5
6
  isContentLoading: boolean;
6
7
  ref: import('react').RefObject<HTMLDivElement>;
7
- connect: (username: string | null | undefined, isEns?: boolean) => void;
8
- ydoc: import('yjs').Doc;
9
- isCollaborationReady: boolean;
10
- syncError: {
11
- message: string;
12
- } | null;
13
- isSyncFetchingFromIpfs: boolean;
8
+ connect: (username: string | null | undefined, isEns?: boolean) => () => void;
9
+ ydoc: Y.Doc;
14
10
  };
@@ -0,0 +1,17 @@
1
+ export declare const base64ToArrayBuffer: (base64String: string) => ArrayBufferLike;
2
+ export declare const arrayBufferToBase64: (buffer: ArrayBuffer) => string;
3
+ export declare const generateRSAKeyPair: () => Promise<{
4
+ publicKey: ArrayBuffer;
5
+ privateKey: Uint8Array;
6
+ }>;
7
+ export declare const decryptAESKey: (encryptedKeyBase64: string, privateKeyPem: BufferSource) => Promise<ArrayBuffer>;
8
+ export declare const decryptImageData: (encryptedImageData: ArrayBuffer, aesKeyBuffer: ArrayBuffer, iv: string) => Promise<ArrayBuffer>;
9
+ export declare const fetchImage: (url: string) => Promise<ArrayBuffer | undefined>;
10
+ type DecryptImage = {
11
+ encryptedKey: string;
12
+ privateKey: BufferSource;
13
+ iv: string;
14
+ imageBuffer: ArrayBuffer;
15
+ };
16
+ export declare const decryptImage: ({ encryptedKey, privateKey, iv, imageBuffer, }: DecryptImage) => Promise<ArrayBuffer | undefined>;
17
+ export {};
@@ -3,5 +3,7 @@ import { DecorationSet, EditorView } from '@tiptap/pm/view';
3
3
 
4
4
  declare const UploadImagesPlugin: () => Plugin<DecorationSet>;
5
5
  export default UploadImagesPlugin;
6
- export declare function startImageUpload(file: File, view: EditorView, pos: number): void;
6
+ export declare function startImageUpload(file: File, view: EditorView, pos: number, secureImageUploadUrl?: string): Promise<void>;
7
7
  export declare const uploadFn: (image: File) => Promise<string>;
8
+ export declare const uploadSecureImage: (url: string, image: File, publicKey: ArrayBuffer) => Promise<any>;
9
+ export declare const handleDecryptImage: (url: string, encryptedKey: string, privateKey: string, iv: string) => Promise<string | undefined>;