@layers-app/editor 0.0.21 → 0.0.22

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 CHANGED
@@ -1,10 +1,18 @@
1
1
  import { CLEAR_EDITOR_COMMAND } from 'lexical';
2
+ import { DOMExportOutput } from 'lexical';
2
3
  import { Dropzone } from '@mantine/dropzone';
4
+ import { EditorConfig } from 'lexical';
3
5
  import { LexicalEditor as EditorType } from 'lexical';
6
+ import { ElementNode } from 'lexical';
4
7
  import { FOCUS_COMMAND } from 'lexical';
5
8
  import { JSX as JSX_2 } from 'react/jsx-runtime';
9
+ import { MarkNode } from '@lexical/mark';
10
+ import { NodeKey } from 'lexical';
11
+ import { RangeSelection } from 'lexical';
6
12
  import { SerializedEditorState } from 'lexical';
13
+ import { SerializedElementNode } from 'lexical';
7
14
  import { SerializedLexicalNode } from 'lexical';
15
+ import { Spread } from 'lexical';
8
16
 
9
17
  export declare type ActiveUserProfile<DATA extends object> = EditorUser<DATA> & {
10
18
  id: string;
@@ -12,9 +20,11 @@ export declare type ActiveUserProfile<DATA extends object> = EditorUser<DATA> &
12
20
 
13
21
  export { CLEAR_EDITOR_COMMAND }
14
22
 
23
+ declare type CommentResolve = 'ACCEPTED' | 'REJECTED' | null;
24
+
15
25
  export { Dropzone }
16
26
 
17
- export declare const Editor: <USER_DATA extends object, CHILD_PAGE extends PageData>({ initialContent, onChange, outputFormat, mode, maxHeight, onBlur, onFocus, fetchUploadMedia, fetchDeleteMedia, maxImageSize, contentModalUploadImage, maxImageSizeError, debounce: debounceMs, disable, ws, excludeNodes, imagePickerSettings, childPages, language, editorRef, }: EditorProps<USER_DATA, CHILD_PAGE>) => JSX_2.Element;
27
+ export declare const Editor: <USER_DATA extends object, CHILD_PAGE extends PageData>({ initialContent, onChange, outputFormat, mode, maxHeight, onBlur, onFocus, fetchUploadMedia, fetchDeleteMedia, currentUser, commentOptions, workspaceMembers, maxImageSize, contentModalUploadImage, maxImageSizeError, debounce: debounceMs, disable, ws, excludeNodes, imagePickerSettings, childPages, language, editorRef, }: EditorProps<USER_DATA, CHILD_PAGE>) => JSX_2.Element;
18
28
 
19
29
  declare interface EditorProps<USER_DATA extends object = object, PAGE_DATA extends PageData = PageData> {
20
30
  initialContent: Root | string;
@@ -29,6 +39,9 @@ declare interface EditorProps<USER_DATA extends object = object, PAGE_DATA exten
29
39
  maxImageSize?: number;
30
40
  contentModalUploadImage?: React.FunctionComponent;
31
41
  maxImageSizeError?: () => void;
42
+ currentUser?: IUser;
43
+ commentOptions?: ICommentOptions;
44
+ workspaceMembers?: IMember[];
32
45
  debounce?: number;
33
46
  disable?: boolean;
34
47
  ws?: EditorWebSocketProps<USER_DATA>;
@@ -58,12 +71,109 @@ declare interface EditorWebSocketProps<USER_DATA extends object> {
58
71
 
59
72
  declare type ErrorDeleteImage = (error?: Error) => void;
60
73
 
74
+ export declare class ExtendMarkNode extends MarkNode implements ElementNode {
75
+ __extendIds: string[];
76
+ __resolve: CommentResolve;
77
+ constructor(idsExtend: string[], resolve?: CommentResolve, key?: NodeKey);
78
+ static getType(): string;
79
+ static clone(node: ExtendMarkNode): ExtendMarkNode;
80
+ static importJSON(serializedNode: SerializedMarkNode): ExtendMarkNode;
81
+ static importDOM(): null;
82
+ resolveThreat(value: CommentResolve): CommentResolve;
83
+ createDOM(config: EditorConfig): HTMLElement;
84
+ exportDOM(editor: EditorType): DOMExportOutput;
85
+ updateDOM(prevNode: MarkNode, element: HTMLElement, config: EditorConfig): boolean;
86
+ exportJSON(): SerializedMarkNode;
87
+ excludeFromCopy(_destination: 'clone' | 'html'): boolean;
88
+ updateExtendId(tempId: string, realId: string): void;
89
+ }
90
+
61
91
  declare type fetchDeleteMedia = (id: string, success: SuccessDeleteImage, error?: ErrorDeleteImage) => void;
62
92
 
63
93
  declare type fetchUploadMedia = (file: File, success: SuccessUploadImage, error?: ErrorDeleteImage) => void;
64
94
 
65
95
  export { FOCUS_COMMAND }
66
96
 
97
+ declare interface ICommentActions {
98
+ fetchCommentsApi: (params: IFetchCommentsParams) => Promise<void>;
99
+ resolveCommentApi: (params: IResolveCommentParams) => Promise<void>;
100
+ commentReactionApi: (params: ICommentReactionParams) => Promise<void>;
101
+ deleteReactionApi: (params: IDeleteReactionParams) => Promise<void>;
102
+ deleteCommentApi: (params: IDeleteCommentParams) => Promise<void>;
103
+ restoreCommentApi: (params: IRestoreCommentParams) => Promise<void>;
104
+ updateCommentTextApi: (params: IUpdateCommentTextParams) => Promise<void>;
105
+ deleteCommentImageApi: (params: IDeleteCommentImageParams) => Promise<void>;
106
+ submitCommentApi: (params: ISubmitCommentParams) => Promise<void>;
107
+ getReactionsApi: (params: IGetReactionsParams) => Promise<{
108
+ content: ICommentReaction[];
109
+ }>;
110
+ getPhotosApi: (params: IGetPhotosParams) => Promise<File[]>;
111
+ uploadCommentFileApi: (params: IUploadCommentFileParams) => Promise<void>;
112
+ }
113
+
114
+ declare interface ICommentOptions {
115
+ showComments: boolean;
116
+ setShowComments: (value?: boolean) => void;
117
+ pageId: string;
118
+ workspaceInfo: {
119
+ title: string;
120
+ icon: string;
121
+ };
122
+ commentActions: ICommentActions;
123
+ }
124
+
125
+ declare interface ICommentReaction {
126
+ id: string;
127
+ commentId: string;
128
+ parentId: string;
129
+ parentType: 'COMMENT' | 'THREAD';
130
+ reaction: string;
131
+ userId: string;
132
+ createdAt: string;
133
+ deleted: boolean;
134
+ deletedAt: string;
135
+ version: number;
136
+ }
137
+
138
+ declare interface ICommentReactionParams {
139
+ commentId: string;
140
+ author: string;
141
+ emojiValue: string;
142
+ onSuccess?: (data: ICommentReaction) => void;
143
+ onError: () => void;
144
+ }
145
+
146
+ declare interface IDeleteCommentImageParams {
147
+ photoToRemove: string;
148
+ onSuccess?: () => void;
149
+ }
150
+
151
+ declare interface IDeleteCommentParams {
152
+ deleteCommentId: string;
153
+ onSuccess?: () => void;
154
+ }
155
+
156
+ declare interface IDeleteReactionParams {
157
+ reactionId: string;
158
+ onSuccess?: () => void;
159
+ onError: () => void;
160
+ }
161
+
162
+ declare interface IFetchCommentsParams {
163
+ fetchPageComments?: boolean;
164
+ pageId: string;
165
+ fetchCommentComments?: boolean;
166
+ onSuccess: (data: any) => void;
167
+ }
168
+
169
+ declare interface IGetPhotosParams {
170
+ commentId: string;
171
+ }
172
+
173
+ declare interface IGetReactionsParams {
174
+ commentId: string;
175
+ }
176
+
67
177
  declare type ImagePickerSettings = {
68
178
  maxUploadFiles?: number;
69
179
  unsplashClientId?: string;
@@ -72,8 +182,79 @@ declare type ImagePickerSettings = {
72
182
  link?: boolean;
73
183
  };
74
184
 
185
+ declare interface IMember {
186
+ accepted: boolean;
187
+ avatarUrl: string;
188
+ email: string;
189
+ expiresAt: string | null;
190
+ invitationId: string | null;
191
+ invitationToken: string | null;
192
+ name: string;
193
+ roleType: string;
194
+ roleId: string;
195
+ userId: string;
196
+ }
197
+
198
+ declare interface IResolveCommentParams {
199
+ threatId: string;
200
+ resolveValue: 'ACCEPTED' | 'REJECTED';
201
+ onSuccess?: () => void;
202
+ onError?: () => void;
203
+ }
204
+
205
+ declare interface IRestoreCommentParams {
206
+ commentId: string;
207
+ onSuccess?: () => void;
208
+ }
209
+
210
+ declare interface ISubmitCommentParams {
211
+ text: string;
212
+ parentType: string;
213
+ parentId: string;
214
+ onSuccess?: (data: any) => void;
215
+ }
216
+
217
+ declare interface IUpdateCommentTextParams {
218
+ commentId: string;
219
+ textValue: string;
220
+ onSuccess?: () => void;
221
+ onError?: () => void;
222
+ }
223
+
224
+ declare interface IUploadCommentFileParams {
225
+ file: File;
226
+ commentId: string;
227
+ onSuccess?: (data: any) => void;
228
+ }
229
+
230
+ declare interface IUser {
231
+ activeWorkspaceId: string;
232
+ createdAt: string;
233
+ darkMode: boolean;
234
+ email: string;
235
+ id: string;
236
+ lang: string;
237
+ metaData: {
238
+ cover: Record<string, any>;
239
+ about: string;
240
+ socialNetworks: any[];
241
+ fontFamily: string;
242
+ };
243
+ name: string;
244
+ nickname: string;
245
+ plan: 'FREE' | 'PRO' | 'BUSINESS' | string;
246
+ profilePicture: {
247
+ url: string;
248
+ };
249
+ timeZone: string | null;
250
+ twoFactorEnabled: boolean;
251
+ workspaces: any[];
252
+ }
253
+
75
254
  declare type Mode = 'comment' | 'default' | 'full' | 'editor';
76
255
 
256
+ export { NodeKey }
257
+
77
258
  declare type outputFormat = 'html' | 'json';
78
259
 
79
260
  declare interface PageData {
@@ -83,8 +264,14 @@ declare interface PageData {
83
264
  order: number;
84
265
  }
85
266
 
267
+ export { RangeSelection }
268
+
86
269
  export declare type Root = SerializedEditorState<SerializedLexicalNode>;
87
270
 
271
+ declare type SerializedMarkNode = Spread<{
272
+ ids: Array<string>;
273
+ }, SerializedElementNode>;
274
+
88
275
  export declare const StylesProvider: ({ children }: {
89
276
  children: React.ReactNode;
90
277
  }) => JSX_2.Element;