@layers-app/editor 0.0.16 → 0.0.17-editor-01

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