@fileverse-dev/ddoc 1.8.0 → 1.8.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/README.md +2 -0
- package/dist/index.es.js +26984 -22437
- package/dist/index.umd.js +199 -124
- package/dist/packages/ddoc/use-ddoc-editor.d.ts +2 -3
- package/dist/packages/ddoc/utils/CollaborationCursor.d.ts +83 -0
- package/package.json +3 -3
@@ -1,9 +1,8 @@
|
|
1
1
|
import { DdocProps } from './types';
|
2
2
|
|
3
|
-
import * as Y from 'yjs';
|
4
3
|
export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration, collaborationId, walletAddress, username, onChange, onCollaboratorChange, onCommentInteraction, onTextSelection, ensResolutionUrl, onError, setCharacterCount, setWordCount, }: Partial<DdocProps>) => {
|
5
4
|
editor: import('@tiptap/react').Editor | null;
|
6
5
|
ref: import('react').RefObject<HTMLDivElement>;
|
7
|
-
connect: (username: string | null | undefined,
|
8
|
-
ydoc:
|
6
|
+
connect: (username: string | null | undefined, _isEns?: boolean) => void;
|
7
|
+
ydoc: import('yjs').Doc;
|
9
8
|
};
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
2
|
+
|
3
|
+
type CollaborationCursorStorage = {
|
4
|
+
users: {
|
5
|
+
clientId: number;
|
6
|
+
[key: string]: any;
|
7
|
+
}[];
|
8
|
+
};
|
9
|
+
export interface CollaborationCursorOptions {
|
10
|
+
/**
|
11
|
+
* The Hocuspocus provider instance. This can also be a TiptapCloudProvider instance.
|
12
|
+
* @type {HocuspocusProvider | TiptapCloudProvider}
|
13
|
+
* @example new HocuspocusProvider()
|
14
|
+
*/
|
15
|
+
provider: any;
|
16
|
+
/**
|
17
|
+
* The user details object – feel free to add properties to this object as needed
|
18
|
+
* @example { name: 'John Doe', color: '#305500' }
|
19
|
+
*/
|
20
|
+
user: Record<string, any>;
|
21
|
+
/**
|
22
|
+
* A function that returns a DOM element for the cursor.
|
23
|
+
* @param user The user details object
|
24
|
+
* @example
|
25
|
+
* render: user => {
|
26
|
+
* const cursor = document.createElement('span')
|
27
|
+
* cursor.classList.add('collaboration-cursor__caret')
|
28
|
+
* cursor.setAttribute('style', `border-color: ${user.color}`)
|
29
|
+
*
|
30
|
+
* const label = document.createElement('div')
|
31
|
+
* label.classList.add('collaboration-cursor__label')
|
32
|
+
* label.setAttribute('style', `background-color: ${user.color}`)
|
33
|
+
* label.insertBefore(document.createTextNode(user.name), null)
|
34
|
+
*
|
35
|
+
* cursor.insertBefore(label, null)
|
36
|
+
* return cursor
|
37
|
+
* }
|
38
|
+
*/
|
39
|
+
render(user: Record<string, any>): HTMLElement;
|
40
|
+
/**
|
41
|
+
* A function that returns a ProseMirror DecorationAttrs object for the selection.
|
42
|
+
* @param user The user details object
|
43
|
+
* @example
|
44
|
+
* selectionRender: user => {
|
45
|
+
* return {
|
46
|
+
* nodeName: 'span',
|
47
|
+
* class: 'collaboration-cursor__selection',
|
48
|
+
* style: `background-color: ${user.color}`,
|
49
|
+
* 'data-user': user.name,
|
50
|
+
* }
|
51
|
+
*/
|
52
|
+
selectionRender(user: Record<string, any>): any;
|
53
|
+
/**
|
54
|
+
* @deprecated The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor
|
55
|
+
*/
|
56
|
+
onUpdate: (users: {
|
57
|
+
clientId: number;
|
58
|
+
[key: string]: any;
|
59
|
+
}[]) => null;
|
60
|
+
}
|
61
|
+
declare module '@tiptap/core' {
|
62
|
+
interface Commands<ReturnType> {
|
63
|
+
collaborationCursor: {
|
64
|
+
/**
|
65
|
+
* Update details of the current user
|
66
|
+
* @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })
|
67
|
+
*/
|
68
|
+
updateUser: (attributes: Record<string, any>) => ReturnType;
|
69
|
+
/**
|
70
|
+
* Update details of the current user
|
71
|
+
*
|
72
|
+
* @deprecated The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor
|
73
|
+
*/
|
74
|
+
user: (attributes: Record<string, any>) => ReturnType;
|
75
|
+
};
|
76
|
+
}
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* This extension allows you to add collaboration cursors to your editor.
|
80
|
+
* @see https://tiptap.dev/api/extensions/collaboration-cursor
|
81
|
+
*/
|
82
|
+
export declare const CollaborationCursor: Extension<CollaborationCursorOptions, CollaborationCursorStorage>;
|
83
|
+
export {};
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@fileverse-dev/ddoc",
|
3
3
|
"private": false,
|
4
4
|
"description": "DDoc",
|
5
|
-
"version": "1.8.
|
5
|
+
"version": "1.8.2",
|
6
6
|
"main": "dist/index.umd.js",
|
7
7
|
"module": "dist/index.es.js",
|
8
8
|
"exports": {
|
@@ -28,6 +28,7 @@
|
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
30
|
"@_ueberdosis/prosemirror-tables": "^1.1.3",
|
31
|
+
"@fileverse-dev/fileverse-sync": "^0.0.4",
|
31
32
|
"@radix-ui/react-focus-scope": "^1.1.0",
|
32
33
|
"@radix-ui/react-popover": "^1.0.7",
|
33
34
|
"@tippyjs/react": "^4.2.6",
|
@@ -76,8 +77,7 @@
|
|
76
77
|
"vaul": "^0.9.1",
|
77
78
|
"vite-plugin-dts": "^3.6.3",
|
78
79
|
"y-prosemirror": "^1.2.5",
|
79
|
-
"y-webrtc": "^10.3.0"
|
80
|
-
"yjs": "^13.6.15"
|
80
|
+
"y-webrtc": "^10.3.0"
|
81
81
|
},
|
82
82
|
"devDependencies": {
|
83
83
|
"@types/dompurify": "^3.0.5",
|