stream-chat-react 12.5.0 → 12.5.1
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.
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
// dataTransferItemsHaveFiles,
|
|
4
|
-
dataTransferItemsToFiles, } from '../../ReactFileUtilities';
|
|
2
|
+
import { dataTransferItemsToFiles } from '../../ReactFileUtilities';
|
|
5
3
|
import { SetLinkPreviewMode } from '../types';
|
|
6
4
|
export const usePasteHandler = (uploadNewFiles, insertText, isUploadEnabled, findAndEnqueueURLsToEnrich) => {
|
|
7
5
|
const onPaste = useCallback((clipboardEvent) => {
|
|
@@ -24,17 +22,16 @@ export const usePasteHandler = (uploadNewFiles, insertText, isUploadEnabled, fin
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
const fileLikes = await dataTransferItemsToFiles(Array.from(items));
|
|
27
|
-
if (fileLikes.length && isUploadEnabled) {
|
|
28
|
-
uploadNewFiles(fileLikes);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
// fallback to regular text paste
|
|
32
25
|
if (plainTextPromise) {
|
|
33
26
|
const pastedText = await plainTextPromise;
|
|
34
27
|
insertText(pastedText);
|
|
35
28
|
findAndEnqueueURLsToEnrich?.(pastedText, SetLinkPreviewMode.UPSERT);
|
|
36
29
|
findAndEnqueueURLsToEnrich?.flush();
|
|
37
30
|
}
|
|
31
|
+
else if (fileLikes.length && isUploadEnabled) {
|
|
32
|
+
uploadNewFiles(fileLikes);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
38
35
|
})(clipboardEvent);
|
|
39
36
|
}, [findAndEnqueueURLsToEnrich, insertText, isUploadEnabled, uploadNewFiles]);
|
|
40
37
|
return { onPaste };
|
package/dist/index.browser.cjs
CHANGED
|
@@ -38059,15 +38059,14 @@ var usePasteHandler = (uploadNewFiles, insertText, isUploadEnabled, findAndEnque
|
|
|
38059
38059
|
}
|
|
38060
38060
|
}
|
|
38061
38061
|
const fileLikes = await dataTransferItemsToFiles(Array.from(items));
|
|
38062
|
-
if (fileLikes.length && isUploadEnabled) {
|
|
38063
|
-
uploadNewFiles(fileLikes);
|
|
38064
|
-
return;
|
|
38065
|
-
}
|
|
38066
38062
|
if (plainTextPromise) {
|
|
38067
38063
|
const pastedText = await plainTextPromise;
|
|
38068
38064
|
insertText(pastedText);
|
|
38069
38065
|
findAndEnqueueURLsToEnrich?.(pastedText, 0 /* UPSERT */);
|
|
38070
38066
|
findAndEnqueueURLsToEnrich?.flush();
|
|
38067
|
+
} else if (fileLikes.length && isUploadEnabled) {
|
|
38068
|
+
uploadNewFiles(fileLikes);
|
|
38069
|
+
return;
|
|
38071
38070
|
}
|
|
38072
38071
|
})(clipboardEvent);
|
|
38073
38072
|
},
|