Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Video] Allow drag-and-drop & pasting video (#5252)

* allow DnD/pasting video

* rm await

authored by

Samuel Newman and committed by
GitHub
08f5f37b 6bc5a05f

+23 -9
+6 -2
src/view/com/composer/Composer.tsx
··· 303 303 const onPhotoPasted = useCallback( 304 304 async (uri: string) => { 305 305 track('Composer:PastedPhotos') 306 - await gallery.paste(uri) 306 + if (uri.startsWith('data:video/')) { 307 + selectVideo({uri, type: 'video', height: 0, width: 0}) 308 + } else { 309 + await gallery.paste(uri) 310 + } 307 311 }, 308 - [gallery, track], 312 + [gallery, track, selectVideo], 309 313 ) 310 314 311 315 const isAltTextRequiredAndMissing = useMemo(() => {
+17 -7
src/view/com/composer/text-input/TextInput.web.tsx
··· 93 93 } 94 94 }, [onPressPublish]) 95 95 React.useEffect(() => { 96 - textInputWebEmitter.addListener('photo-pasted', onPhotoPasted) 96 + textInputWebEmitter.addListener('media-pasted', onPhotoPasted) 97 97 return () => { 98 - textInputWebEmitter.removeListener('photo-pasted', onPhotoPasted) 98 + textInputWebEmitter.removeListener('media-pasted', onPhotoPasted) 99 99 } 100 100 }, [onPhotoPasted]) 101 101 ··· 105 105 if (transfer) { 106 106 const items = transfer.items 107 107 108 - getImageFromUri(items, (uri: string) => { 109 - textInputWebEmitter.emit('photo-pasted', uri) 108 + getImageOrVideoFromUri(items, (uri: string) => { 109 + textInputWebEmitter.emit('media-pasted', uri) 110 110 }) 111 111 } 112 112 ··· 160 160 view.pasteText(text) 161 161 preventDefault = true 162 162 } 163 - getImageFromUri(clipboardData.items, (uri: string) => { 164 - textInputWebEmitter.emit('photo-pasted', uri) 163 + getImageOrVideoFromUri(clipboardData.items, (uri: string) => { 164 + textInputWebEmitter.emit('media-pasted', uri) 165 165 }) 166 166 if (preventDefault) { 167 167 // Return `true` to prevent ProseMirror's default paste behavior. ··· 346 346 }, 347 347 }) 348 348 349 - function getImageFromUri( 349 + function getImageOrVideoFromUri( 350 350 items: DataTransferItemList, 351 351 callback: (uri: string) => void, 352 352 ) { ··· 363 363 if (blob.type.startsWith('image/')) { 364 364 blobToDataUri(blob).then(callback, err => console.error(err)) 365 365 } 366 + 367 + if (blob.type.startsWith('video/')) { 368 + blobToDataUri(blob).then(callback, err => console.error(err)) 369 + } 366 370 } 367 371 }) 368 372 } else if (type.startsWith('image/')) { 373 + const file = item.getAsFile() 374 + 375 + if (file) { 376 + blobToDataUri(file).then(callback, err => console.error(err)) 377 + } 378 + } else if (type.startsWith('video/')) { 369 379 const file = item.getAsFile() 370 380 371 381 if (file) {