You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/React/components/contexts/message-input-context.mdx
+22-65Lines changed: 22 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,11 +29,11 @@ Additional props to be passed to the underlying `AutoCompleteTextarea` component
29
29
30
30
### attachments
31
31
32
-
An array of attachments added to the current message.
32
+
An array of attachments added to the current message. Every attachment object carries attribute `localMetadata` that is internally used to manage the attachment state in the composer (update, remove attachments from the state, keep reference to uploaded files, keep information about the file upload state). The `localMetadata` object is discarded from each attachment object before sending the resulting message to the server. The attachments array does not contain attachments created by URL enrichment. These scraped attachments are kept in `linkPreviews` map.
33
33
34
-
| Type |
35
-
| ------------ |
36
-
|Attachment[]|
34
+
| Type |
35
+
| -----------------|
36
+
|LocalAttachment[]|
37
37
38
38
### autocompleteTriggers
39
39
@@ -181,22 +181,6 @@ Custom error handler function to be called with a file/image upload fails.
The order in which file attachments have been added to the current message.
187
-
188
-
| Type |
189
-
| -------- |
190
-
| string[]|
191
-
192
-
### fileUploads
193
-
194
-
A mapping of the file attachments added to the current message.
195
-
196
-
| Type |
197
-
| ---------------------------- |
198
-
|{ [id: string]: FileUpload}|
199
-
200
184
### findAndEnqueueURLsToEnrich
201
185
202
186
A function responsible for initiating URL discovery and their subsequent enrichment. It is available only if link preview rendering is enabled. Link previews are disabled by default.
@@ -253,22 +237,6 @@ Allows to hide MessageInput's send button. Used by `MessageSimple` to hide the s
253
237
| ------- | ------- |
254
238
| boolean | false |
255
239
256
-
### imageOrder
257
-
258
-
The order in which image attachments have been added to the current message.
259
-
260
-
| Type |
261
-
| -------- |
262
-
| string[]|
263
-
264
-
### imageUploads
265
-
266
-
A mapping of the image attachments added to the current message.
267
-
268
-
| Type |
269
-
| ----------------------------- |
270
-
|{ [id: string]: ImageUpload}|
271
-
272
240
### insertText
273
241
274
242
Function to insert text into the value of the underlying `textarea` component.
@@ -304,7 +272,7 @@ If specified, this function overrides the default behavior specified previously.
304
272
305
273
### maxFilesLeft
306
274
307
-
The maximum number of allowed uploads minus the current number of uploads.
275
+
The maximum number of allowed uploads minus the current number of successful uploads.
308
276
309
277
| Type |
310
278
| ------ |
@@ -368,7 +336,7 @@ If true, disables file uploads for all attachments except for those with type 'i
368
336
369
337
### numberOfUploads
370
338
371
-
The number of file uploads on the current message.
339
+
The number of successfully uploaded files for the current message.
372
340
373
341
| Type |
374
342
| ------ |
@@ -468,22 +436,6 @@ const Component = () => {
468
436
};
469
437
```
470
438
471
-
### removeFile
472
-
473
-
Function to remove a file from the `fileUploads` mapping.
474
-
475
-
| Type |
476
-
| -------------------- |
477
-
| (id: string) => void |
478
-
479
-
### removeImage
480
-
481
-
Function to remove an image from the `imageUploads` mapping.
482
-
483
-
| Type |
484
-
| -------------------- |
485
-
| (id: string) => void |
486
-
487
439
### setCooldownRemaining
488
440
489
441
React state hook function that sets the `cooldownRemaining` value.
@@ -532,25 +484,30 @@ React mutable ref placed on the underlying `textarea` component.
532
484
| -------------------------------------------- |
533
485
| React.MutableRefObject<HTMLTextAreaElement\>|
534
486
535
-
### uploadFile
487
+
### uploadAttachment
536
488
537
-
Function to upload a fileto the `fileUploads` mapping.
489
+
Uploads the file that comes as a part of the `attachment` object argument. The function expects the `attachment` object to contain attribute `localMetadata`, which in turn should contain `file` attribute referring to the file to be uploaded and an attribute `id` with attachment's unique identifier string. The `localMetadata` object is discarded when the message is posted.
538
490
539
-
| Type |
540
-
| -------------------- |
541
-
| (id: string) => void |
491
+
So the minimum required `attachment` object for upload would be:
542
492
543
-
### uploadImage
493
+
```
494
+
type MinimumUploadAttachment = {
495
+
localMetadata: {
496
+
file: File | Blob;
497
+
id: string;
498
+
}
499
+
}
500
+
```
544
501
545
-
Function to upload an image.
502
+
The function returns `undefined` if, custom upload function (`doImageUploadRequest`, `doFileUploadRequest`) fails.
0 commit comments