@liveblocks/emails 2.13.2 → 2.13.3-emails2
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.mts +201 -9
- package/dist/index.d.ts +201 -9
- package/dist/index.js +8387 -207
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8402 -222
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise,
|
|
1
|
+
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, DRI, CommentBody } from '@liveblocks/core';
|
|
2
2
|
export { ResolveUsersArgs } from '@liveblocks/core';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Properties } from 'csstype';
|
|
5
|
-
import { Liveblocks, ThreadNotificationEvent } from '@liveblocks/node';
|
|
5
|
+
import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* CSS properties object.
|
|
@@ -95,20 +95,212 @@ declare type ConvertCommentBodyAsHtmlStyles = {
|
|
|
95
95
|
link: CSSProperties;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
declare type
|
|
98
|
+
declare type ResolveRoomInfoArgs = {
|
|
99
|
+
/**
|
|
100
|
+
* The ID of the room to resolve
|
|
101
|
+
*/
|
|
102
|
+
roomId: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Liveblocks Text Editor
|
|
107
|
+
*
|
|
108
|
+
* Expose common types to transform nodes from different editors like `Lexical` or `TipTap`
|
|
109
|
+
* and then convert them more easily as React or as html.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
declare type LiveblocksTextEditorTextFormat = {
|
|
113
|
+
bold: boolean;
|
|
114
|
+
italic: boolean;
|
|
115
|
+
strikethrough: boolean;
|
|
116
|
+
code: boolean;
|
|
117
|
+
};
|
|
118
|
+
declare type LiveblocksTextEditorTextNode = {
|
|
119
|
+
type: "text";
|
|
120
|
+
text: string;
|
|
121
|
+
} & LiveblocksTextEditorTextFormat;
|
|
122
|
+
declare type LiveblocksTextEditorMentionNode = {
|
|
123
|
+
type: "mention";
|
|
124
|
+
userId: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* -------------------------------------------------------------------------------------------------
|
|
128
|
+
* `LiveblocksTextEditorNode` is common structure to represents text editor nodes coming from
|
|
129
|
+
* like `Lexical`, `TipTap` or so.
|
|
130
|
+
*
|
|
131
|
+
* This (simple) structure is made to be scalable and to accommodate with other text editors we could potentially
|
|
132
|
+
* want to support in the future.
|
|
133
|
+
*
|
|
134
|
+
* It allows to manipulate nodes more easily and converts them with ease either as React nodes or as an html safe string.
|
|
135
|
+
* From a DX standpoint it provides to developers the same structure to use when using custom React components or inline css
|
|
136
|
+
* to represents a text mention with its surrounding text.
|
|
137
|
+
* -------------------------------------------------------------------------------------------------
|
|
138
|
+
*/
|
|
139
|
+
declare type LiveblocksTextEditorNode = LiveblocksTextEditorTextNode | LiveblocksTextEditorMentionNode;
|
|
140
|
+
declare type TextEditorContainerComponentProps = {
|
|
141
|
+
/**
|
|
142
|
+
* The nodes of the text editor
|
|
143
|
+
*/
|
|
144
|
+
children: React.ReactNode;
|
|
145
|
+
};
|
|
146
|
+
declare type TextEditorMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
147
|
+
/**
|
|
148
|
+
* The mention element.
|
|
149
|
+
*/
|
|
150
|
+
element: LiveblocksTextEditorMentionNode;
|
|
151
|
+
/**
|
|
152
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
153
|
+
*/
|
|
154
|
+
user?: U["info"];
|
|
155
|
+
};
|
|
156
|
+
declare type TextEditorTextComponentProps = {
|
|
157
|
+
/**
|
|
158
|
+
* The text element.
|
|
159
|
+
*/
|
|
160
|
+
element: LiveblocksTextEditorTextNode;
|
|
161
|
+
};
|
|
162
|
+
declare type ConvertTextEditorNodesAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* The component used to act as a container to wrap text editor nodes,
|
|
166
|
+
*/
|
|
167
|
+
Container: React.ComponentType<TextEditorContainerComponentProps>;
|
|
168
|
+
/**
|
|
169
|
+
* The component used to display mentions.
|
|
170
|
+
*/
|
|
171
|
+
Mention: React.ComponentType<TextEditorMentionComponentProps<U>>;
|
|
172
|
+
/**
|
|
173
|
+
* The component used to display text nodes.
|
|
174
|
+
*/
|
|
175
|
+
Text: React.ComponentType<TextEditorTextComponentProps>;
|
|
176
|
+
};
|
|
177
|
+
declare type ConvertTextEditorNodesAsHtmlStyles = {
|
|
178
|
+
/**
|
|
179
|
+
* The default inline CSS styles used to display container element.
|
|
180
|
+
*/
|
|
181
|
+
container: CSSProperties;
|
|
182
|
+
/**
|
|
183
|
+
* The default inline CSS styles used to display text `<strong />` elements.
|
|
184
|
+
*/
|
|
185
|
+
strong: CSSProperties;
|
|
186
|
+
/**
|
|
187
|
+
* The default inline CSS styles used to display text `<code />` elements.
|
|
188
|
+
*/
|
|
189
|
+
code: CSSProperties;
|
|
190
|
+
/**
|
|
191
|
+
* The default inline CSS styles used to display mentions.
|
|
192
|
+
*/
|
|
193
|
+
mention: CSSProperties;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
declare type MentionEmailBaseData = {
|
|
99
197
|
id: string;
|
|
100
|
-
threadId: string;
|
|
101
198
|
roomId: string;
|
|
102
199
|
userId: string;
|
|
200
|
+
textEditorNodes: LiveblocksTextEditorNode[];
|
|
103
201
|
createdAt: Date;
|
|
104
|
-
url?: string;
|
|
105
|
-
rawBody: CommentBody;
|
|
106
202
|
};
|
|
107
|
-
declare type
|
|
203
|
+
declare type PrepareTextMentionNotificationEmailBaseDataOptions = {
|
|
108
204
|
/**
|
|
109
|
-
*
|
|
205
|
+
* A function that returns room info from room IDs.
|
|
110
206
|
*/
|
|
207
|
+
resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
|
|
208
|
+
};
|
|
209
|
+
declare type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
|
|
210
|
+
author: U;
|
|
211
|
+
reactContent: React.ReactNode;
|
|
212
|
+
};
|
|
213
|
+
declare type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
|
|
214
|
+
author: U;
|
|
215
|
+
htmlContent: string;
|
|
216
|
+
};
|
|
217
|
+
declare type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
|
|
218
|
+
/**
|
|
219
|
+
* A function that returns info from user IDs.
|
|
220
|
+
*/
|
|
221
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
222
|
+
/**
|
|
223
|
+
* The components used to customize the resulting React nodes. Each components has
|
|
224
|
+
* priority over the base components inherited.
|
|
225
|
+
*/
|
|
226
|
+
components?: Partial<ConvertTextEditorNodesAsReactComponents<U>>;
|
|
227
|
+
};
|
|
228
|
+
declare type TextMentionNotificationEmailData<U extends BaseUserMeta, M extends MentionEmailAsReactData<U> | MentionEmailAsHtmlData<U>> = {
|
|
229
|
+
mention: M;
|
|
230
|
+
roomInfo: DRI;
|
|
231
|
+
};
|
|
232
|
+
declare type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsReactData>;
|
|
233
|
+
/**
|
|
234
|
+
* Prepares data from a `TextMentionNotificationEvent` and convert content as React nodes.
|
|
235
|
+
*
|
|
236
|
+
* @param client The `Liveblocks` node client
|
|
237
|
+
* @param event The `TextMentionNotificationEvent` received in the webhook handler
|
|
238
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
239
|
+
*
|
|
240
|
+
* It returns a `TextMentionNotificationEmailDataAsReact` or `null` if there are no existing text mention.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
244
|
+
* import { prepareTextMentionNotificationEmailAsReact } from "@liveblocks/emails"
|
|
245
|
+
*
|
|
246
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
247
|
+
* const emailData = prepareTextMentionNotificationEmailAsReact(
|
|
248
|
+
* liveblocks,
|
|
249
|
+
* event,
|
|
250
|
+
* {
|
|
251
|
+
* resolveUsers,
|
|
252
|
+
* resolveRoomInfo,
|
|
253
|
+
* components,
|
|
254
|
+
* }
|
|
255
|
+
* )
|
|
256
|
+
*/
|
|
257
|
+
declare function prepareTextMentionNotificationEmailAsReact(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsReactOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsReact | null>;
|
|
258
|
+
declare type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
|
|
259
|
+
/**
|
|
260
|
+
* A function that returns info from user IDs.
|
|
261
|
+
*/
|
|
262
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* The styles used to customize the html elements in the resulting html safe string.
|
|
265
|
+
* Each styles has priority over the base styles inherited.
|
|
266
|
+
*/
|
|
267
|
+
styles?: Partial<ConvertTextEditorNodesAsHtmlStyles>;
|
|
268
|
+
};
|
|
269
|
+
declare type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsHtmlData>;
|
|
270
|
+
/**
|
|
271
|
+
* Prepares data from a `TextMentionNotificationEvent` and convert content as an html safe string.
|
|
272
|
+
*
|
|
273
|
+
* @param client The `Liveblocks` node client
|
|
274
|
+
* @param event The `TextMentionNotificationEvent` received in the webhook handler
|
|
275
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
276
|
+
*
|
|
277
|
+
* It returns a `TextMentionNotificationEmailDataAsReact` or `null` if there are no existing text mention.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
281
|
+
* import { prepareTextMentionNotificationEmailAsHtml } from "@liveblocks/emails"
|
|
282
|
+
*
|
|
283
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
284
|
+
* const emailData = prepareTextMentionNotificationEmailAsHtml(
|
|
285
|
+
* liveblocks,
|
|
286
|
+
* event,
|
|
287
|
+
* {
|
|
288
|
+
* resolveUsers,
|
|
289
|
+
* resolveRoomInfo,
|
|
290
|
+
* styles,
|
|
291
|
+
* }
|
|
292
|
+
* )
|
|
293
|
+
*/
|
|
294
|
+
declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsHtml | null>;
|
|
295
|
+
|
|
296
|
+
declare type CommentEmailBaseData = {
|
|
297
|
+
id: string;
|
|
298
|
+
threadId: string;
|
|
111
299
|
roomId: string;
|
|
300
|
+
userId: string;
|
|
301
|
+
createdAt: Date;
|
|
302
|
+
url?: string;
|
|
303
|
+
rawBody: CommentBody;
|
|
112
304
|
};
|
|
113
305
|
declare type PrepareThreadNotificationEmailBaseDataOptions = {
|
|
114
306
|
/**
|
|
@@ -213,4 +405,4 @@ declare type ThreadNotificationEmailDataAsReact = ThreadNotificationEmailData<Ba
|
|
|
213
405
|
*/
|
|
214
406
|
declare function prepareThreadNotificationEmailAsReact(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsReactOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsReact | null>;
|
|
215
407
|
|
|
216
|
-
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|
|
408
|
+
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type ConvertTextEditorNodesAsHtmlStyles, type ConvertTextEditorNodesAsReactComponents, type MentionEmailAsHtmlData, type MentionEmailAsReactData, type PrepareTextMentionNotificationEmailAsHtmlOptions, type PrepareTextMentionNotificationEmailAsReactOptions, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type TextEditorContainerComponentProps, type TextEditorMentionComponentProps, type TextEditorTextComponentProps, type TextMentionNotificationEmailDataAsHtml, type TextMentionNotificationEmailDataAsReact, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareTextMentionNotificationEmailAsHtml, prepareTextMentionNotificationEmailAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise,
|
|
1
|
+
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, DRI, CommentBody } from '@liveblocks/core';
|
|
2
2
|
export { ResolveUsersArgs } from '@liveblocks/core';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Properties } from 'csstype';
|
|
5
|
-
import { Liveblocks, ThreadNotificationEvent } from '@liveblocks/node';
|
|
5
|
+
import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* CSS properties object.
|
|
@@ -95,20 +95,212 @@ declare type ConvertCommentBodyAsHtmlStyles = {
|
|
|
95
95
|
link: CSSProperties;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
declare type
|
|
98
|
+
declare type ResolveRoomInfoArgs = {
|
|
99
|
+
/**
|
|
100
|
+
* The ID of the room to resolve
|
|
101
|
+
*/
|
|
102
|
+
roomId: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Liveblocks Text Editor
|
|
107
|
+
*
|
|
108
|
+
* Expose common types to transform nodes from different editors like `Lexical` or `TipTap`
|
|
109
|
+
* and then convert them more easily as React or as html.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
declare type LiveblocksTextEditorTextFormat = {
|
|
113
|
+
bold: boolean;
|
|
114
|
+
italic: boolean;
|
|
115
|
+
strikethrough: boolean;
|
|
116
|
+
code: boolean;
|
|
117
|
+
};
|
|
118
|
+
declare type LiveblocksTextEditorTextNode = {
|
|
119
|
+
type: "text";
|
|
120
|
+
text: string;
|
|
121
|
+
} & LiveblocksTextEditorTextFormat;
|
|
122
|
+
declare type LiveblocksTextEditorMentionNode = {
|
|
123
|
+
type: "mention";
|
|
124
|
+
userId: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* -------------------------------------------------------------------------------------------------
|
|
128
|
+
* `LiveblocksTextEditorNode` is common structure to represents text editor nodes coming from
|
|
129
|
+
* like `Lexical`, `TipTap` or so.
|
|
130
|
+
*
|
|
131
|
+
* This (simple) structure is made to be scalable and to accommodate with other text editors we could potentially
|
|
132
|
+
* want to support in the future.
|
|
133
|
+
*
|
|
134
|
+
* It allows to manipulate nodes more easily and converts them with ease either as React nodes or as an html safe string.
|
|
135
|
+
* From a DX standpoint it provides to developers the same structure to use when using custom React components or inline css
|
|
136
|
+
* to represents a text mention with its surrounding text.
|
|
137
|
+
* -------------------------------------------------------------------------------------------------
|
|
138
|
+
*/
|
|
139
|
+
declare type LiveblocksTextEditorNode = LiveblocksTextEditorTextNode | LiveblocksTextEditorMentionNode;
|
|
140
|
+
declare type TextEditorContainerComponentProps = {
|
|
141
|
+
/**
|
|
142
|
+
* The nodes of the text editor
|
|
143
|
+
*/
|
|
144
|
+
children: React.ReactNode;
|
|
145
|
+
};
|
|
146
|
+
declare type TextEditorMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
147
|
+
/**
|
|
148
|
+
* The mention element.
|
|
149
|
+
*/
|
|
150
|
+
element: LiveblocksTextEditorMentionNode;
|
|
151
|
+
/**
|
|
152
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
153
|
+
*/
|
|
154
|
+
user?: U["info"];
|
|
155
|
+
};
|
|
156
|
+
declare type TextEditorTextComponentProps = {
|
|
157
|
+
/**
|
|
158
|
+
* The text element.
|
|
159
|
+
*/
|
|
160
|
+
element: LiveblocksTextEditorTextNode;
|
|
161
|
+
};
|
|
162
|
+
declare type ConvertTextEditorNodesAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* The component used to act as a container to wrap text editor nodes,
|
|
166
|
+
*/
|
|
167
|
+
Container: React.ComponentType<TextEditorContainerComponentProps>;
|
|
168
|
+
/**
|
|
169
|
+
* The component used to display mentions.
|
|
170
|
+
*/
|
|
171
|
+
Mention: React.ComponentType<TextEditorMentionComponentProps<U>>;
|
|
172
|
+
/**
|
|
173
|
+
* The component used to display text nodes.
|
|
174
|
+
*/
|
|
175
|
+
Text: React.ComponentType<TextEditorTextComponentProps>;
|
|
176
|
+
};
|
|
177
|
+
declare type ConvertTextEditorNodesAsHtmlStyles = {
|
|
178
|
+
/**
|
|
179
|
+
* The default inline CSS styles used to display container element.
|
|
180
|
+
*/
|
|
181
|
+
container: CSSProperties;
|
|
182
|
+
/**
|
|
183
|
+
* The default inline CSS styles used to display text `<strong />` elements.
|
|
184
|
+
*/
|
|
185
|
+
strong: CSSProperties;
|
|
186
|
+
/**
|
|
187
|
+
* The default inline CSS styles used to display text `<code />` elements.
|
|
188
|
+
*/
|
|
189
|
+
code: CSSProperties;
|
|
190
|
+
/**
|
|
191
|
+
* The default inline CSS styles used to display mentions.
|
|
192
|
+
*/
|
|
193
|
+
mention: CSSProperties;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
declare type MentionEmailBaseData = {
|
|
99
197
|
id: string;
|
|
100
|
-
threadId: string;
|
|
101
198
|
roomId: string;
|
|
102
199
|
userId: string;
|
|
200
|
+
textEditorNodes: LiveblocksTextEditorNode[];
|
|
103
201
|
createdAt: Date;
|
|
104
|
-
url?: string;
|
|
105
|
-
rawBody: CommentBody;
|
|
106
202
|
};
|
|
107
|
-
declare type
|
|
203
|
+
declare type PrepareTextMentionNotificationEmailBaseDataOptions = {
|
|
108
204
|
/**
|
|
109
|
-
*
|
|
205
|
+
* A function that returns room info from room IDs.
|
|
110
206
|
*/
|
|
207
|
+
resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
|
|
208
|
+
};
|
|
209
|
+
declare type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
|
|
210
|
+
author: U;
|
|
211
|
+
reactContent: React.ReactNode;
|
|
212
|
+
};
|
|
213
|
+
declare type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
|
|
214
|
+
author: U;
|
|
215
|
+
htmlContent: string;
|
|
216
|
+
};
|
|
217
|
+
declare type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
|
|
218
|
+
/**
|
|
219
|
+
* A function that returns info from user IDs.
|
|
220
|
+
*/
|
|
221
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
222
|
+
/**
|
|
223
|
+
* The components used to customize the resulting React nodes. Each components has
|
|
224
|
+
* priority over the base components inherited.
|
|
225
|
+
*/
|
|
226
|
+
components?: Partial<ConvertTextEditorNodesAsReactComponents<U>>;
|
|
227
|
+
};
|
|
228
|
+
declare type TextMentionNotificationEmailData<U extends BaseUserMeta, M extends MentionEmailAsReactData<U> | MentionEmailAsHtmlData<U>> = {
|
|
229
|
+
mention: M;
|
|
230
|
+
roomInfo: DRI;
|
|
231
|
+
};
|
|
232
|
+
declare type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsReactData>;
|
|
233
|
+
/**
|
|
234
|
+
* Prepares data from a `TextMentionNotificationEvent` and convert content as React nodes.
|
|
235
|
+
*
|
|
236
|
+
* @param client The `Liveblocks` node client
|
|
237
|
+
* @param event The `TextMentionNotificationEvent` received in the webhook handler
|
|
238
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
239
|
+
*
|
|
240
|
+
* It returns a `TextMentionNotificationEmailDataAsReact` or `null` if there are no existing text mention.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
244
|
+
* import { prepareTextMentionNotificationEmailAsReact } from "@liveblocks/emails"
|
|
245
|
+
*
|
|
246
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
247
|
+
* const emailData = prepareTextMentionNotificationEmailAsReact(
|
|
248
|
+
* liveblocks,
|
|
249
|
+
* event,
|
|
250
|
+
* {
|
|
251
|
+
* resolveUsers,
|
|
252
|
+
* resolveRoomInfo,
|
|
253
|
+
* components,
|
|
254
|
+
* }
|
|
255
|
+
* )
|
|
256
|
+
*/
|
|
257
|
+
declare function prepareTextMentionNotificationEmailAsReact(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsReactOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsReact | null>;
|
|
258
|
+
declare type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
|
|
259
|
+
/**
|
|
260
|
+
* A function that returns info from user IDs.
|
|
261
|
+
*/
|
|
262
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* The styles used to customize the html elements in the resulting html safe string.
|
|
265
|
+
* Each styles has priority over the base styles inherited.
|
|
266
|
+
*/
|
|
267
|
+
styles?: Partial<ConvertTextEditorNodesAsHtmlStyles>;
|
|
268
|
+
};
|
|
269
|
+
declare type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsHtmlData>;
|
|
270
|
+
/**
|
|
271
|
+
* Prepares data from a `TextMentionNotificationEvent` and convert content as an html safe string.
|
|
272
|
+
*
|
|
273
|
+
* @param client The `Liveblocks` node client
|
|
274
|
+
* @param event The `TextMentionNotificationEvent` received in the webhook handler
|
|
275
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
276
|
+
*
|
|
277
|
+
* It returns a `TextMentionNotificationEmailDataAsReact` or `null` if there are no existing text mention.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
281
|
+
* import { prepareTextMentionNotificationEmailAsHtml } from "@liveblocks/emails"
|
|
282
|
+
*
|
|
283
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
284
|
+
* const emailData = prepareTextMentionNotificationEmailAsHtml(
|
|
285
|
+
* liveblocks,
|
|
286
|
+
* event,
|
|
287
|
+
* {
|
|
288
|
+
* resolveUsers,
|
|
289
|
+
* resolveRoomInfo,
|
|
290
|
+
* styles,
|
|
291
|
+
* }
|
|
292
|
+
* )
|
|
293
|
+
*/
|
|
294
|
+
declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsHtml | null>;
|
|
295
|
+
|
|
296
|
+
declare type CommentEmailBaseData = {
|
|
297
|
+
id: string;
|
|
298
|
+
threadId: string;
|
|
111
299
|
roomId: string;
|
|
300
|
+
userId: string;
|
|
301
|
+
createdAt: Date;
|
|
302
|
+
url?: string;
|
|
303
|
+
rawBody: CommentBody;
|
|
112
304
|
};
|
|
113
305
|
declare type PrepareThreadNotificationEmailBaseDataOptions = {
|
|
114
306
|
/**
|
|
@@ -213,4 +405,4 @@ declare type ThreadNotificationEmailDataAsReact = ThreadNotificationEmailData<Ba
|
|
|
213
405
|
*/
|
|
214
406
|
declare function prepareThreadNotificationEmailAsReact(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsReactOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsReact | null>;
|
|
215
407
|
|
|
216
|
-
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|
|
408
|
+
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type ConvertTextEditorNodesAsHtmlStyles, type ConvertTextEditorNodesAsReactComponents, type MentionEmailAsHtmlData, type MentionEmailAsReactData, type PrepareTextMentionNotificationEmailAsHtmlOptions, type PrepareTextMentionNotificationEmailAsReactOptions, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type TextEditorContainerComponentProps, type TextEditorMentionComponentProps, type TextEditorTextComponentProps, type TextMentionNotificationEmailDataAsHtml, type TextMentionNotificationEmailDataAsReact, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareTextMentionNotificationEmailAsHtml, prepareTextMentionNotificationEmailAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|